xsl-list
[Top] [All Lists]

xsl:number with level=any

2004-10-12 17:41:40
How exactly should the number be calculated in xsl:number when level=any?
In particular, are the context node and the node matching the "from"
expression both counted if they match the "count" expression?

The algorithm in the XSLT 2.0 draft seems to count both, and xsltproc
does this.  Xalan and xt seem to not count the from node.  I can't
work out what saxon is doing.

For concreteness, here is a stylesheet and a document.  What should
the output be?

Stylesheet:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:template match="/">
 <doc>
  <xsl:text>&#10;</xsl:text>
  <xsl:apply-templates/>
  <xsl:text>&#10;</xsl:text>
 </doc>
</xsl:template>

<xsl:template match="*">
  <xsl:copy>
    <xsl:attribute name="count">
      <xsl:number level="any" count="x" from="/*"/>
    </xsl:attribute>
    <xsl:apply-templates select="node()"/>
  </xsl:copy>
</xsl:template>

</xsl:stylesheet>

Document:

<x>
 <x/>
 <x/>
</x>

-- Richard


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