<?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>29148</bug_id>
          
          <creation_ts>2015-09-24 08:54:56 +0000</creation_ts>
          <short_desc>[XSLT30] Text on constructing complex content says that document nodes are removed, but this is not always true</short_desc>
          <delta_ts>2015-10-29 12:42:32 +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>Last Call drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>WORKSFORME</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="Abel Braaksma">abel.braaksma</reporter>
          <assigned_to name="Michael Kay">mike</assigned_to>
          
          
          <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>123305</commentid>
    <comment_count>0</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2015-09-24 08:54:56 +0000</bug_when>
    <thetext>Under 5.8.1 Constructing Complex Content, we write (4th item):

4. Any document node within the result sequence is replaced by a sequence containing each of its children, in document order.

However, when inside an xsl:variable, the result sequence implicitly contains a document node. This document node is not removed. Conversely, if you write:

&lt;xsl:variable&gt;
    &lt;xsl:document&gt;+

you could say that the document not is not removed either, as the xsl:variable will not have to be converted into a variable containing a document node.

Likewise, if you have as=&quot;document-node()&quot;, the sequence is required to create a document node and it is not removed (if we did so, it would invalidate the variable).

Though I am unsure how this could be written more clearly (rules elsewhere are clear), I stumbled upon it, considering it an (albeit small) ambiguity.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123308</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-09-24 21:40:19 +0000</bug_when>
    <thetext>The rules for xsl:variable do not invoke the rules for constructing complex content.

The CCC rules are used only (IIRC) by xsl:document, xsl:element, literal result elements, xsl:copy, xsl:result-document.

xsl:value-of, xsl:comment, xsl:attribute etc use the rules for constructing simple content.

xsl:variable, xsl:param, xsl:with-param use the rules for values of variables in 9.3; these do not replace document nodes by their content.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123310</commentid>
    <comment_count>2</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2015-09-25 02:20:13 +0000</bug_when>
    <thetext>Deja-vu feeling, did I report this before? If so, I must suffer of tunnel-vision ;).

I found in 9.3 Values of Variables and Parameters

&quot;The content of the variable-binding element is a sequence constructor; a new document is constructed with a document node having as its children the sequence of nodes that results from evaluating the sequence constructor and then applying the rules given in 5.7.1 Constructing Complex Content. &quot;

So I guess that covers it. However:

&gt; The rules for xsl:variable do not invoke the rules for constructing 
&gt; complex content.
I came here by:

5.7 Sequence constructors
--&gt; 5.7.1. Constructing Complex Content

after following this text:

&quot;The sequence may be used to construct the content of a new element or document node. [....] It also happens when the sequence constructor is contained in one of the elements xsl:variable, xsl:param, or xsl:with-param, when this instruction has no as attribute. For details, see 5.7.1 Constructing Complex Content.&quot;

I could argue that this is a misleading path through the spec, but I think other places in the spec (9.3 mentioned above) cover this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123329</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-09-28 09:50:32 +0000</bug_when>
    <thetext>OK, sorry, my rationale here was not quite right (shouldn&apos;t try this kind of thing while on vacation...). But I think I was close, and I don&apos;t think there is a bug.

5.7.1 starts by saying: &quot;This section describes how the sequence obtained by evaluating a sequence constructor may be used to construct the children of a newly constructed document node, or the children, attributes and namespaces of a newly constructed element node.&quot;

9.3 says: If a variable-binding element has no select attribute and has non-empty content (that is, the variable-binding element has one or more child nodes), and has no as attribute, then the content of the variable-binding element specifies the supplied value. The content of the variable-binding element is a sequence constructor; a new document is constructed with a document node having as its children the sequence of nodes that results from evaluating the sequence constructor and then applying the rules given in 5.7.1 Constructing Complex Content. The value of the variable is then a singleton sequence containing this document node. 

So 9.3 says we create a document node and use the rules in 5.7.1 to create its children. The document node itself is not part of the sequence obtained by evaluating the sequence constructor, so rule 4 (&quot;Any document node within the result sequence is replaced by a sequence containing each of its children, in document order.&quot;) does not affect it.

It&apos;s true that the language could be tightened up (we don&apos;t define the term &quot;result sequence&quot;, for example). But if it was good enough for 2.0 I can&apos;t really see that there&apos;s a pressing need to change it now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123336</commentid>
    <comment_count>4</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2015-09-28 11:53:47 +0000</bug_when>
    <thetext>I wrote:
&gt; I could argue that this is a misleading path through the spec, but I think 
&gt; other places in the spec (9.3 mentioned above) cover this.

You wrote:
&gt; But if it was good enough for 2.0 I can&apos;t really see that there&apos;s a 
&gt; pressing need to change it now.

Summarizing, definitely not &quot;pressing&quot;, I suggest to close with no action.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123489</commentid>
    <comment_count>5</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2015-10-05 21:49:38 +0000</bug_when>
    <thetext>I am closing this as &quot;worksforme&quot;, as I raised this bug, the issue is cleared up now and the spec prose works. See comment#3 for clarification.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>