[xslt] XPath weirdness



I'm observing the following with the latest libxml/libxslt versions.

XML:
-snip-
<nodes>
  <categorynode catid="1">
    <categorytext>One</categorytext>
  </categorynode>
  <categorynode catid="2">
    <categorytext>Two</categorytext>
  </categorynode>
  <categorynode catid="1">
    <categorytext>Three</categorytext>
  </categorynode>
</nodes>
-/snip-

XSLT #1:
-snip-
<xsl:stylesheet
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     version="1.0">

<xsl:variable name="catid" select="'1'"/>

<xsl:template match="categorynode[@catid = $catid]">
  <xsl:variable name="test" select="(parent::*)//categorynode[@catid = $catid]"/>
  <xsl:if test="not(generate-id($test[1]) != generate-id(.))">
    XXX: <xsl:value-of select="categorytext"/>
  </xsl:if>
</xsl:template>

</xsl:stylesheet>
-/snip-

XSLT #2 (which inlines $test above):
-snip-
<xsl:template match="categorynode[@catid = $catid]">
  <xsl:if test="not(generate-id(((parent::*)//categorynode[@catid = $catid])[1]) != generate-id(.))">
    XXX: <xsl:value-of select="categorytext"/>
  </xsl:if>
</xsl:template>
-/snip-

XSLT #2 fails the xsl:if-test, whereas XSLT #1 passes the XXX-line to the
output.

                                                                   robert




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]