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 11460 - [XSLT 3.0] Context for xsl:merge-key
Summary: [XSLT 3.0] Context for xsl:merge-key
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XSLT 3.0 (show other bugs)
Version: Working 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: 2010-12-03 12:17 UTC by Michael Kay
Modified: 2012-03-08 18:29 UTC (History)
0 users

See Also:


Attachments

Description Michael Kay 2010-12-03 12:17:49 UTC
The content model for xsl:merge-input is

<xsl:merge-input
  select? = expression >
  <!-- Content: (sequence-constructor, xsl:merge-key+) -->
</xsl:merge-input>

This makes it legal to write

<xsl:merge-input>
  <xsl:variable name="o">ascending</xsl:variable>
  <xsl:sequence select="abcd"/>
  <xsl:merge-key select="." order="{$o}"/>
</xsl:merge-input>

But this is meaningless: the criteria for sorting/merging cannot depend in this way on the data to be sorted. It's legal because of an accident of the rules for variable scope: rather than saying that the scope of a variable is the rest of the sequence constructor, we say that it is all following sibling elements of the xsl:variable.

Proposed solution: in 9.7, after the following:

<quote>
A local variable binding element is visible for all following siblings and their descendants, with the following exceptions:

1. It is not visible in any region where it is shadowed by another variable binding.

2. It is not visible within the subtree rooted at an xsl:fallback instruction that is a sibling of the variable binding element.

3. It is not visible within the subtree rooted at an xsl:catch instruction that is a sibling of the variable binding element.
</quote>

add a fourth exception:

4. It is not visible within the subtree rooted at an xsl:merge-key instruction that is a sibling of the variable binding element.
Comment 1 Michael Kay 2012-02-17 14:23:29 UTC
We came up with a different solution: drop the possibility of using a sequence constructor as a child of xsl:merge-input, leaving xsl:merge-key as the only child element. There is no loss of functionality because the select expression can always call a function. Keeping open for the moment as this proposed solution needs study.
Comment 2 Michael Kay 2012-03-08 18:28:54 UTC
The WG decided to drop the option of supplying a sequence constructor as a child of xsl:merge-input (which under bug #11372 is now combined with xsl:merge-source). The main use case for the sequence constructor was to allow xsl:perform-sort to be applied to the input sequence, and the need for this has been eliminated by adding the attribute sort-before-merge="yes|no".