<?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>11460</bug_id>
          
          <creation_ts>2010-12-03 12:17:49 +0000</creation_ts>
          <short_desc>[XSLT 3.0] Context for xsl:merge-key</short_desc>
          <delta_ts>2012-03-08 18:29:10 +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>Working drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</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>
          
          
          <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>43013</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2010-12-03 12:17:49 +0000</bug_when>
    <thetext>The content model for xsl:merge-input is

&lt;xsl:merge-input
  select? = expression &gt;
  &lt;!-- Content: (sequence-constructor, xsl:merge-key+) --&gt;
&lt;/xsl:merge-input&gt;

This makes it legal to write

&lt;xsl:merge-input&gt;
  &lt;xsl:variable name=&quot;o&quot;&gt;ascending&lt;/xsl:variable&gt;
  &lt;xsl:sequence select=&quot;abcd&quot;/&gt;
  &lt;xsl:merge-key select=&quot;.&quot; order=&quot;{$o}&quot;/&gt;
&lt;/xsl:merge-input&gt;

But this is meaningless: the criteria for sorting/merging cannot depend in this way on the data to be sorted. It&apos;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:

&lt;quote&gt;
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.
&lt;/quote&gt;

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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64227</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2012-02-17 14:23:29 +0000</bug_when>
    <thetext>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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65146</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2012-03-08 18:28:54 +0000</bug_when>
    <thetext>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=&quot;yes|no&quot;.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>