<?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>28762</bug_id>
          
          <creation_ts>2015-06-04 19:45:25 +0000</creation_ts>
          <short_desc>[XSLT30] Focus of xsl:merge-key&apos;s select attribute and sequence constructor</short_desc>
          <delta_ts>2015-08-17 08:41:32 +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>Last Call 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="Abel Braaksma">abel.braaksma</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>120716</commentid>
    <comment_count>0</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2015-06-04 19:45:25 +0000</bug_when>
    <thetext>This bug originated by XSLWG mail: https://lists.w3.org/Archives/Member/w3c-xsl-wg/2015Apr/0063.html (member only).

This bug was discussed and confirmed by the XSLWG telcon of 2015-06-04, see minutes: https://lists.w3.org/Archives/Member/w3c-xsl-wg/2015Jun/0011.html (member only).

The spec does not say what the focus is for the select attribute or the sequence constructor of xsl:merge-key. It should (probably) be set to the context item set by the select attribute of xsl:merge-source. 

Suggestion from the aforementioned mail is:

&quot;We should probably do something similar as has been done for xsl:merge-action, where we clearly define the context item, position and size.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>120723</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-06-05 10:40:38 +0000</bug_when>
    <thetext>I propose to define the evaluation of merge keys as follows:

&lt;p diff=&quot;add&quot; at=&quot;S-bug28762&quot;&gt;The value of &lt;var&gt;N&lt;/var&gt;th merge key value of an item &lt;var&gt;J&lt;/var&gt; in a &lt;termref
               def=&quot;dt-merge-input-sequence&quot;&gt;merge input sequence&lt;/termref&gt; &lt;var&gt;S&lt;/var&gt; is the result of the expression
            in the &lt;code&gt;select&lt;/code&gt; attribute of the &lt;var&gt;N&lt;/var&gt;th &lt;elcode&gt;xsl:merge-key&lt;/elcode&gt; child of the
            corresponding &lt;elcode&gt;xsl:merge-source&lt;/elcode&gt; element, or in the absence of the &lt;code&gt;select&lt;/code&gt; attribute, the result of the contained
            &lt;termref def=&quot;dt-sequence-constructor&quot;/&gt;, evaluated with a &lt;termref def=&quot;dt-focus&quot;/&gt; in which the &lt;termref def=&quot;dt-context-item&quot;/&gt; is
            &lt;var&gt;J&lt;/var&gt;, the &lt;termref def=&quot;dt-context-position&quot;/&gt; is the position of &lt;var&gt;J&lt;/var&gt; within &lt;var&gt;S&lt;/var&gt;, and
            the &lt;termref def=&quot;dt-context-size&quot;/&gt; is the number of items in &lt;var&gt;S&lt;/var&gt;.&lt;/p&gt;

However, for this to work we need to change the definition of &quot;merge input sequence&quot; to be (in the case where sort-before-merge=&quot;yes&quot;) the sequence prior to sorting, rather than, as currently, the sequence after sorting. This appears to work.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>120724</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-06-05 12:44:46 +0000</bug_when>
    <thetext>Thinking about this again... I chose those rules to be consistent with the rules for xsl:sort keys. But sorting assumes you have the whole sequence available, while merging is all designed for streamability. So I don&apos;t think allowing use of position() and last() (in relation to the full input sequence) make much sense. I propose instead to use a singleton focus based on the individual item.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>120727</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-06-05 13:31:32 +0000</bug_when>
    <thetext>I have applied the solution that uses a singleton focus, but leaving the bug open for WG review. Note also that when streaming, the context item for evaluating the key is the snapshot node, not the original (we already say this).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>121551</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-07-01 19:51:35 +0000</bug_when>
    <thetext>The WG approved the proposed solution on 18 Jun 2015.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122632</commentid>
    <comment_count>5</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-08-17 08:41:32 +0000</bug_when>
    <thetext>The change has been applied to the specification.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>