XSLT string comparison issue

every time i do this comparison in my transform:
<xsl:value-of select="'$300,000.00' &gt; '$155,000.00'" />
it returns false.  Seems to me that it should return true.  What am i missing here?

abemiesterAsked:
Who is Participating?
 
zc2Connect With a Mentor Commented:
the processor converts the strings to numbers and gets NaN
when you compare two NaNs it will be always false:

Even
<xsl:value-of select="number('s') = number('s')" />
returns false.

To correctly compare the strings as numbers you need to strip all invalid characters:
<xsl:value-of select="number(translate('$300,000.00','$,','')) &gt; number(translate('$155,000.00','$,',''))" />

Open in new window

0
 
abemiesterAuthor Commented:
Why is it converting them to numbers?  I thought it would do a string compare unless i specified otherwise...
0
 
zc2Commented:
it's by the W3 recommendation
http://www.w3.org/TR/xpath#booleans
(read the paragraph after the first NOTE)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.