This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 29305 - [XT30TS] number-3501, 3229, 4001
Summary: [XT30TS] number-3501, 3229, 4001
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XSLT 3.0 Test Suite (show other bugs)
Version: Candidate Recommendation
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Abel Braaksma
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
Depends on:
Reported: 2015-11-25 12:07 UTC by Tim Mills
Modified: 2016-02-18 11:42 UTC (History)
2 users (show)

See Also:


Description Tim Mills 2015-11-25 12:07:00 UTC
Having concurred with these results for some years, after re-implementing xsl:number carefully, I think the expected results are incorrect.  

Taking as an example nmber-3501, the input starts:

<!-- Test for source tree numbering -->
  <title>Test for source tree numbering</title>
    <title>First Chapter</title>

and the transformation applies

<xsl:template match="chapter//title">
  <xsl:number level="multiple" from="chapter"
      format="A.1.a. "/>
  <xsl:value-of select="."/><xsl:text>

and the expected result given for the first chapter/title above is ". First Chapter".

Following the rules for xsl:number level="multiple"

S = the title element with content "First Chapter" (/doc[1]/chapter[1]/title[1])
F = first chapter node in document (/doc[1]/chapter[1])
A = first chapter node in document (/doc[1]/chapter[1])
AF = first chapter node in document (/doc[1]/chapter[1])


 for $af in $AF
  return 1+count($af/preceding-sibling::node()[local:matches-count(.)])

gives 1 + count(()), i.e. 1, which should format as "A." (which seems correct intuitively).

The following XQuery might help...

declare function local:matches-count($arg)
  typeswitch ($arg)
  case element(chapter) return true()
  case element(section) return true()
  case element(subsection) return ($arg/../subsection[1] is $arg)
  default return false()

declare function local:matches-from($arg)
  typeswitch ($arg)
  case element(chapter) return true()
  default return root($arg) is $arg

let $S := /doc[1]/chapter[1]/title[1]
let $A := $S/ancestor-or-self::node()[local:matches-count(.)]
let $F := $S/ancestor-or-self::node()[local:matches-from(.)][1]
let $AF := $A[ancestor-or-self::node()[. is $F]]
  "S = ", $S,
  "A = ", $A,
  "F = ", $F,
  "AF = ", $AF,
  for $af in $AF
  return 1+count($af/preceding-sibling::node()[local:matches-count(.)])
Comment 1 Abel Braaksma 2016-02-16 16:12:25 UTC
We have assessed these tests during the F2F meeting in XML Prague, Feb 16, 2016 and after some discussion and re-reading of the relevant sections of the spec we agree with your conclusions.

We will fix the tests shortly, issue assigned.
Comment 2 Michael Kay 2016-02-16 16:21:29 UTC
The issue appears to be that the test results match the 1.0 spec, which said:

If the from attribute is specified, then the only ancestors that are searched are those that are descendants of the nearest ancestor that matches the from pattern.

rather than the 2.0 spec, which effectively substitutes "descendants-or-self" for "descendants" in the above rule.
Comment 3 Michael Kay 2016-02-18 11:21:50 UTC
I have committed new expected results for these three tests. Please confirm that they agree with what you are getting.
Comment 4 Tim Mills 2016-02-18 11:42:14 UTC
Verified fixed.  Thanks.