----- Original Message -----
From: "Kapur, Rajneesh" <Rajneesh(_dot_)Kapur(_at_)Arbella(_dot_)com>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Friday, January 28, 2005 9:31 PM
Subject: [xsl] Finding Even and odd in xslt
Hi,
I want to test whether a number is even or odd. Therefore I have the
following code.
<xsl:variable name="namePadding">9</xsl:variable>
<xsl:variable name="modulas" expr="$namePadding mod 2"/>
<xsl:choose>
<xsl:when test="$modulas=number(1)">
<xsl:variable name="toss">1</xsl:variable>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="toss">0</xsl:variable>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="$toss"/>
But when I print out the value of $toss then processor complains that
"toss"
is not defined.
Thanks in advance,
-raj
617.328.2849
Your variable is out of scope, you need to reverse the xslt:
<xsl:variable name="toss">
<xsl:choose>
<xsl:when test="$modulas=number(1)">1</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
--
Joe
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--