<?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>11372</bug_id>
          
          <creation_ts>2010-11-22 10:08:44 +0000</creation_ts>
          <short_desc>[XSLT 3.0] (11 May 2010), Section 15.3: Merge-source default context</short_desc>
          <delta_ts>2012-03-08 18:25:46 +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>Linux</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="O&apos;Neil Delpratt">oneil</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>42687</commentid>
    <comment_count>0</comment_count>
    <who name="O&apos;Neil Delpratt">oneil</who>
    <bug_when>2010-11-22 10:08:44 +0000</bug_when>
    <thetext>In Section 15.3, and the second paragraph we observe &apos;if the select attribute is omitted, the default value is ., which selects the context item&apos;. There is a potential problem here if the merge instruction, say is written in an  xsl:function, which has no context item passed in, then the xsl:merge-source context item will be undefined. 

For example, in the following function &apos;s:merge1&apos; we have an xsl:merge instruction which has a xsl:merge-source, with the select attribute omitted. For the xsl:merge-key the value of the select is ., this will error as xsl:merge-source does not have a valid context item:

...
&lt;xsl:function name=&quot;s:merge1&quot;&gt;
    &lt;xsl:merge&gt;

        &lt;xsl:merge-source&gt;
            &lt;xsl:merge-input&gt;
                &lt;xsl:perform-sort select=&quot;doc(&apos;europe.xml&apos;)/europe/country&quot;&gt;             
                    &lt;xsl:sort select=&quot;.&quot; order=&quot;ascending&quot;/&gt;
                &lt;/xsl:perform-sort&gt;    
                &lt;xsl:merge-key select=&quot;.&quot;/&gt;
            &lt;/xsl:merge-input&gt;
        &lt;/xsl:merge-source&gt;
        
        &lt;xsl:merge-action&gt;
            &lt;out&gt;
                &lt;xsl:value-of select=&quot;.&quot;/&gt;
            &lt;/out&gt;
        &lt;/xsl:merge-action&gt;
        
    &lt;/xsl:merge&gt;
&lt;/xsl:function&gt;
...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49358</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2011-06-08 22:09:02 +0000</bug_when>
    <thetext>I took an action at the Prague F2F to propose a solution to this one. It&apos;s surprisingly difficult, and I think the reason is that the merge-source/merge-input syntax and semantics are pretty dense. Having the two &quot;select&quot; attributes in a one-to-one relationship with each other is particularly confusing. I think we could do better if we refactored it.

I would like to propose collapsing xsl:merge-source and xsl:merge-input into a single element with the syntax

&lt;xsl:merge-input
  name = qname
  for-each = expression
  select = expression
&gt;

If for-each is present then the merge-input selects multiple input sequences, one for each anchor item selected by the for-each expression, which is used as the context item for evaluating the select expression. If for-each is absent then the merge-input selects a single input sequence, obtained by evaluating the select expression, which is then evaluated using the context of the merge-input instruction itself.

The select expression can be replaced by a contained sequence constructor; the for-each expression can&apos;t.

I think this will make it much clearer what&apos;s going on.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64232</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2012-02-17 14:50:30 +0000</bug_when>
    <thetext>After considering various alternatives the WG began to find the proposal in comment #1 attractive and gave the editor an action to propose detailed text.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65145</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2012-03-08 18:25:25 +0000</bug_when>
    <thetext>The WG reviewed the text in the editor&apos;s draft of the specification and approved it. Note that the sequence constructor option of the xsl:merge-source element has now disappeared; the main use case for it was to contain an xsl:perform-sort instruction, and the need for this has been removed by adding the attribute sort-before-merge=&quot;yes|no&quot; with the default &quot;no&quot;.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>