Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSLT issue with testing for numbers

Status
Not open for further replies.

tshad

Programmer
Jul 15, 2004
386
US
I have the following in my XSLT sheet that test for a number that doesn't work.

If I do:

<xsl:choose>
<xsl:when test="number('j') = 'NaN'">
0
</xsl:when>
<xsl:eek:therwise>
<xsl:value-of select="substring(name(),7,1) - 1"/>
</xsl:eek:therwise>
</xsl:choose>

I have a break on the "0" and the select and no matter what I put in the number() function as a paramter it always takes the otherwise path.

Why doesn't it work?

Thanks,

Tom
 
Have you tried;
Code:
<xsl:choose>
    <xsl:when test="string(number('j'))='NaN'">0</xsl:when>
    <xsl:otherwise>
        <xsl:value-of select="substring(name(),7,1) - 1"/>
    </xsl:otherwise>
</xsl:choose>

...or putting the value in a variable?

Code:
<xsl:variable name="Value.To.Test" select="J"/>
<xsl:choose>
    <xsl:when test="string(number($Value.To.Test))='NaN'">0</xsl:when>
    <xsl:otherwise>
        <xsl:value-of select="substring(name(),7,1) - 1"/>
    </xsl:otherwise>
</xsl:choose>



Rhys

"The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it"
Terry Pratchett
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top