-
Notifications
You must be signed in to change notification settings - Fork 20
Description
In XSLT 3.0, an xsl:variable instruction with no select or as attribute implicitly wraps the value created by the sequence constructor in a document node. This inevitably fails if the content is a map, making it necessary to write
<xsl:variable name="m" as="map(*)">
<xsl:map>...</xsl:map>
</xsl:variable>
I propose that this wrapping should not happen if the first item in the result of the sequence constructor is a function item (including a map or array). The practical effect on users is that they can leave out the as="map(*)" attribute in this situation.
For function items other than arrays, this is currently an error condition so there is no incompatibility.
For arrays it does represent an incompatible change -- the current rules ("Constructing complex content") say that an array is flattened. But XSLT 3.0 has no instruction to construct an array, it would have to be done using xsl:sequence; and no-one would deliberately construct an array merely in order to flatten it, so the situation is unlikely to arise in practice.
The proposal is that the decision whether or not to construct a wrapping document node should be based on the first item in the sequence. This is to allow lazy evaluation. A function item appearing later in the sequence would be handled the same way as now -- most likely an error. An empty sequence continues to result in a childless document node.