[Home] [By Thread] [By Date] [Recent Entries]

Subject: xsl:number with level=any
From: Richard Tobin <richard@xxxxxxxxxxxx>
Date: Wed, 13 Oct 2004 01:41:40 +0100 (BST)
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

Current Thread
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member