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 29148 - [XSLT30] Text on constructing complex content says that document nodes are removed, but this is not always true
Summary: [XSLT30] Text on constructing complex content says that document nodes are re...
Status: CLOSED WORKSFORME
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XSLT 3.0 (show other bugs)
Version: Last Call drafts
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Michael Kay
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-24 08:54 UTC by Abel Braaksma
Modified: 2015-10-29 12:42 UTC (History)
0 users

See Also:


Attachments

Description Abel Braaksma 2015-09-24 08:54:56 UTC
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:

<xsl:variable>
    <xsl:document>+

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="document-node()", 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.
Comment 1 Michael Kay 2015-09-24 21:40:19 UTC
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.
Comment 2 Abel Braaksma 2015-09-25 02:20:13 UTC
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

"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. "

So I guess that covers it. However:

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

5.7 Sequence constructors
--> 5.7.1. Constructing Complex Content

after following this text:

"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."

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.
Comment 3 Michael Kay 2015-09-28 09:50:32 UTC
OK, sorry, my rationale here was not quite right (shouldn't try this kind of thing while on vacation...). But I think I was close, and I don't think there is a bug.

5.7.1 starts by saying: "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."

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 ("Any document node within the result sequence is replaced by a sequence containing each of its children, in document order.") does not affect it.

It's true that the language could be tightened up (we don't define the term "result sequence", for example). But if it was good enough for 2.0 I can't really see that there's a pressing need to change it now.
Comment 4 Abel Braaksma 2015-09-28 11:53:47 UTC
I wrote:
> 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.

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

Summarizing, definitely not "pressing", I suggest to close with no action.
Comment 5 Abel Braaksma 2015-10-05 21:49:38 UTC
I am closing this as "worksforme", as I raised this bug, the issue is cleared up now and the spec prose works. See comment#3 for clarification.