[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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

Subject: XSLT 2.0 xsl:number level="any" with from pattern
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Wed, 04 Aug 2010 14:37:33 +0200
 XSLT 2.0 xsl:number level="any" with from pattern
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[@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[@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/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.