<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>29305</bug_id>
          
          <creation_ts>2015-11-25 12:07:00 +0000</creation_ts>
          <short_desc>[XT30TS]  number-3501, 3229, 4001</short_desc>
          <delta_ts>2016-02-18 11:42:14 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>XSLT 3.0 Test Suite</component>
          <version>Candidate Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Tim Mills">tim</reporter>
          <assigned_to name="Abel Braaksma">abel.online</assigned_to>
          <cc>abel.braaksma</cc>
    
    <cc>mike</cc>
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>124285</commentid>
    <comment_count>0</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2015-11-25 12:07:00 +0000</bug_when>
    <thetext>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:

&lt;!-- Test for source tree numbering --&gt;
&lt;doc&gt;
  &lt;title&gt;Test for source tree numbering&lt;/title&gt;
  &lt;chapter&gt;
    &lt;title&gt;First Chapter&lt;/title&gt;

and the transformation applies

&lt;xsl:template match=&quot;chapter//title&quot;&gt;
  &lt;xsl:number level=&quot;multiple&quot; from=&quot;chapter&quot;
      count=&quot;chapter|section|subsection[1]&quot;
      format=&quot;A.1.a. &quot;/&gt;
  &lt;xsl:value-of select=&quot;.&quot;/&gt;&lt;xsl:text&gt;
&lt;/xsl:text&gt;
&lt;/xsl:template&gt;

and the expected result given for the first chapter/title above is &quot;. First Chapter&quot;.

Following the rules for xsl:number level=&quot;multiple&quot;

S = the title element with content &quot;First Chapter&quot; (/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])

so 

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

gives 1 + count(()), i.e. 1, which should format as &quot;A.&quot; (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]]
return
(
  &quot;S = &quot;, $S,
  &quot;A = &quot;, $A,
  &quot;F = &quot;, $F,
  &quot;AF = &quot;, $AF,
  
  for $af in $AF
  return 1+count($af/preceding-sibling::node()[local:matches-count(.)])
)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>125106</commentid>
    <comment_count>1</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2016-02-16 16:12:25 +0000</bug_when>
    <thetext>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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>125107</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-02-16 16:21:29 +0000</bug_when>
    <thetext>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 &quot;descendants-or-self&quot; for &quot;descendants&quot; in the above rule.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>125134</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-02-18 11:21:50 +0000</bug_when>
    <thetext>I have committed new expected results for these three tests. Please confirm that they agree with what you are getting.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>125135</commentid>
    <comment_count>4</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2016-02-18 11:42:14 +0000</bug_when>
    <thetext>Verified fixed.  Thanks.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>