How to category Design category Development category News category

XSL bitwise comparisons

Need to do a bitwise test inside your XSLT – well without native support you can use the following…

<xml/>
<br />
	<stuff><br />
	Value being checked = <xsl:value-of select="$testvar"><br />
	test bit 1:<xsl:value-of select="number($testvar) mod 2)=1"><br />
	test bit 2:<xsl:value-of select="floor((number($testvar) div 2) mod 2)=1"><br />
	test bit 3:<xsl:value-of select="floor((number($testvar) div 4) mod 2)=1"><br />
	test bit 4:<xsl:value-of select="floor((number($testvar) div 8) mod 2)=1"><br />
	and so on...</xsl:value-of></xsl:value-of></xsl:value-of></xsl:value-of></xsl:value-of></stuff></p>
<p>

Tags:

Jamie

qr code

Leave a Comment

Your more than welcome to enter the discussion, all comments are moderated however - so please don't leave spam, it will be canned...