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?

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:

<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

abemiesterAuthor Commented:
Why is it converting them to numbers?  I thought it would do a string compare unless i specified otherwise...
it's by the W3 recommendation
(read the paragraph after the first NOTE)
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.