<?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>30093</bug_id>
          
          <creation_ts>2017-04-17 11:58:50 +0000</creation_ts>
          <short_desc>[xslt30] Incorrect explanation of example pattern</short_desc>
          <delta_ts>2017-05-31 09:27:51 +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</component>
          <version>Proposed Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</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="Michael Kay">mike</reporter>
          <assigned_to name="Michael Kay">mike</assigned_to>
          <cc>sca.w3c</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>128540</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2017-04-17 11:58:50 +0000</bug_when>
    <thetext>In 5.5.1 we have an example pattern:

//para matches any para element that has a parent node.

This example is incorrect. The normative specification shows that this pattern matches any para element in a tree that is rooted at a document node.

(This error is also present in the XSLT 2.0 specification.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>128573</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2017-05-04 17:43:07 +0000</bug_when>
    <thetext>The WG agreed the change, and I have changed the explanation of the example to say &quot;//para matches any para element in a tree that is rooted at a document node&quot;.

The WG also asked the editor, for the record, to provide a technical explanation of why the example is incorrect.

The relevant rule for the semantics of this pattern is in §5.5.3 (The Meaning of a Pattern) and reads:

an item N matches a pattern P if the following applies, where EE is the equivalent expression to P: N is a node, and the result of evaluating the expression root(.)//(EE) with a singleton focus based on N is a sequence that includes the node N

So //para matches $N if the result of root($N)//(//para) contains N. This expression expands to

root($N)/
  descendant-or-self::node()/
  ( root(.) treat as document-node()/
    descendant-or-self::node()/
    child::para )

If $X is a root node then for every descendant $D of $X, root($D) will be $X. So this can be simplified to

root($N) treat as document-node()/
    descendant-or-self::node()/
    child::para

It is clear that 

(a) all nodes selected by this expression are elements named para

(b) in the case of a para for which root(.) is not a document node, the step (root(.) treat as document node) will fail with a dynamic error, and therefore the pattern will not match

(c) for every element E in a tree that is rooted at a document node, E is either a child of the document node, or a child of a descendant of the document node, and therefore the pattern selects EVERY element named para in such a tree.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>