- From: <bugzilla@wiggum.w3.org>
- Date: Wed, 09 Jul 2008 23:45:07 +0000
- To: public-qt-comments@w3.org
http://www.w3.org/Bugs/Public/show_bug.cgi?id=5849 Summary: [XSLT 2.0] xsl:number problem Product: XPath / XQuery / XSLT Version: Recommendation Platform: PC OS/Version: Windows NT Status: NEW Severity: normal Priority: P2 Component: XSLT 2.0 AssignedTo: mike@saxonica.com ReportedBy: mike@saxonica.com QAContact: public-qt-comments@w3.org I'm not sure whether this really counts as a bug, but it is certainly an oddity. Consider the following source document: <doc> <a mark="true"/> <a/> <a/> <a/> <a mark="true"/> <a/> <a/> <a/> </doc> and the template <xsl:template match="a"> <a> <xsl:copy-of select="@mark"/> <xsl:number level="any" count="a" from="a[@mark='true']"/> </a> </xsl:template> How would you expect the nodes to be numbered? I think the correct answer according to the spec is: <doc> <a mark="true" nr=""/> <a nr="2"/> <a nr="3"/> <a nr="4"/> <a mark="true" nr="5"/> <a nr="2"/> <a nr="3"/> <a nr="4"/> </doc> The explanation is that when you are numbering node X, the algorithm takes no account of whether X matches the from pattern, but it does include the previous node that matched the from pattern in its count, assuming that it also matched the count pattern. I think a less surprising answer would be: <doc> <a mark="true" nr="1"/> <a nr="2"/> <a nr="3"/> <a nr="4"/> <a mark="true" nr="1"/> <a nr="2"/> <a nr="3"/> <a nr="4"/> </doc> which would be achieved by changing Let $F be the node sequence selected by the expression $S/(preceding::node()|ancestor::node())[matches-from(.)][last()] to Let $F be the node sequence selected by the expression $S/(preceding::node()|ancestor-or-self::node())[matches-from(.)][last()] I've no idea, however, what side-effects this might have on other use cases. The XSLT 1.0 rule is "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 this suffers the same problem: a node that matches both "count" and "from" is not numbered 1, but the next counted node is numbered 2. But the sentence is so convoluted that you can read it different ways. -- 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 Wednesday, 9 July 2008 23:45:42 UTC