[Bug 5849] [XSLT 2.0] xsl:number problem

http://www.w3.org/Bugs/Public/show_bug.cgi?id=5849


Henry Zongaro <zongaro@ca.ibm.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |zongaro@ca.ibm.com




--- Comment #1 from Henry Zongaro <zongaro@ca.ibm.com>  2008-07-10 18:55:51 ---
I agree that the sentence that Michael Kay has quoted from XSLT 1.0 is very
difficult to parse - indeed, I believe it contains a typographical error that
exacerbates the problem.  However, when I read it, I believe the expected
result in XSLT 1.0 is as follows:

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

That is, a node that matches the "from" pattern and the "count" pattern is
considered to be the last node of the set that began *after* the last node that
matched the "from" pattern, rather than the first node in new set.

For convenience, I'll refer to the "a" element nodes using XPath expressions
given "doc" as a context node.

The first part of the paragraph on level="any" says, "it constructs a list of
length one containing the number of nodes that match the count pattern and
belong to the set containing the current node and all nodes at any level of the
document that are before the current node in document order."  So for a[2] that
set - prior to considering the "from" pattern - consists of {a[1], a[2]}, and
for a[6], that set consists of {a[1],a[2],...a[6]}.

Then we have, "If the from attribute is specified, then only nodes after the
first node before the current node that match the from pattern are considered."
 I think "match" here is a typographical error, and should be "matches."  The
referent of "that" must be "the first node" not "nodes after the first node,"
because we're counting from the first node that matches the from pattern, we're
not counting only the nodes that match the from pattern.  Thus, "only nodes
after the first node before the current node that matches the from pattern are
considered."  So the preceding node that matched the "from" pattern is not
counted.

So, for a[2], the first node before the current node that matches the from
pattern is a[1].  If we only consider the nodes in {a[1],a[2]} that are after
a[1], we're left with {a[2]} - so the count is 1.  Similarly, for a[6], the
first node before the current node that matches the from pattern is a[5].  If
we only consider nodes in {a[1],a[2],...a[6]} that are after a[5], we're left
with {a[6]} - so the count is again 1.

For a[5] - the second "a" element with mark="true" - the first part of
level="any" has us construct the set {a[1],a[2],...a[5]}.  The qualification
for the "from" attribute has us consider only the nodes after the first node
before a[5] that matches the "from" pattern - i.e., a[1].  So that leaves us
with the set {a[2],a[3],a[4],a[5]}, and the value of the count is 4.

For a[1], the set is initially {a[1]}.  There is no first node before a[1] that
matches the "from" pattern, so I'm guessing that the set that results from the
qualification for "from" is the empty set, and according to erratum E23 for
XSLT 1.0, count is an empty list.


-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

Received on Thursday, 10 July 2008 18:56:26 UTC