xsl-list
[Top] [All Lists]

[xsl] insight into string vs number comparisons?

2007-11-14 09:36:07
I've just encountered a very strange problem, illustrated below.

Source XML
<Records>
  <Record>
     <id>1</id>
   </Record>
  <Record>
    <id>2</id>
  </Record>
</Records>

XSL:

<xsl:variable name="id" select="'2'" />

<xsl:for-each select="/Records/Record">
        [<xsl:value-of select="id=$id" /> (<xsl:value-of select="id"
/>|<xsl:value-of select="$id" />)]
</xsl:for-each>
<xsl:for-each select="/Records/Record">
        [<xsl:value-of select="id=number($id)" /> (<xsl:value-of
select="id" />|<xsl:value-of select="$id" />)]
</xsl:for-each>
Output:

[true (279|279)]  [true (301|279)]         <!-- ?!?!!?! -->
[true (279|279)]  [false (301|279)]       <!-- this is what i'd expect -->

What's going on?

--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>