xsl-list
[Top] [All Lists]

[xsl] XSLT 2.0 xsl:number level="any" with from pattern

2010-08-04 07:37:51

I am struggling to understand whether the root node is used as the boundary node with xsl:number when a from pattern is specified but no preceding or ancestor node matches that from pattern.

As an example, let's say the input XML is

<doc>
  <a/>
  <a/>
  <a/>
  <a/>
  <a mark="true"/>
  <a/>
  <a/>
  <a/>
</doc>

and the XSLT 2.0 stylesheet is

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

  <xsl:output indent="yes"/>

  <xsl:template match="a">
    <a>
      <xsl:copy-of select="@mark"/>
      <xsl:number level="any" count="a" from="a[(_at_)mark='true']"/>
    </a>
  </xsl:template>

</xsl:stylesheet>

Saxon 9.2.1.1 and Intel's processor output the following

  <a/>
  <a/>
  <a/>
  <a/>
  <a mark="true">1</a>
  <a>2</a>
  <a>3</a>
  <a>4</a>

The empty first four 'a' elements mean in my understanding that the xsl:number for these elements did generate an empty sequence as the place marker. I am struggling to understand why that happens, as the specification in http://www.w3.org/TR/xslt20/#numbering-based-on-position defines:

"Let matches-from($node) be a function that returns true if and only if the given node $node matches the pattern given in the from attribute, or if $node is the root node of a tree."

and Mike's book says (page 407):

"Now identify the boundary node. This is the last node (...) that matches the from pattern (...). If the from pattern was not specified, or if none of these nodes matches, use the root of the tree."

With those definitions or explanations I would expect the first four 'a' elements to be numbered 1, 2, 3, 4 as I would compute $F as the root node for each of these four elements. The errata of the specification defines $F as $S/(preceding::node()|ancestor-or-self::node())[matches-from(.)][last()]) and as four the first four 'a' elements there is no preceding or ancestor node that matches the from="a[(_at_)mark='true']" pattern counting should start from the root node.

What am I missing, why do those processors not output a number for the first four 'a' elements?




--

        Martin Honnen
        http://msmvps.com/blogs/martin_honnen/

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