[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Finding Even and odd in xslt

Subject: Re: Finding Even and odd in xslt
From: "Joe Fawcett" <joefawcett@xxxxxxxxxxx>
Date: Fri, 28 Jan 2005 21:37:32 -0000
xslt odd
----- Original Message ----- From: "Kapur, Rajneesh" <Rajneesh.Kapur@xxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Friday, January 28, 2005 9:31 PM
Subject: 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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.