<?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>27536</bug_id>
          
          <creation_ts>2014-12-08 16:14:15 +0000</creation_ts>
          <short_desc>[XP31] Focus for evaluation of keyspecifier in lookup</short_desc>
          <delta_ts>2015-07-16 14:28:30 +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>XPath 3.1</component>
          <version>Last Call drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</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="Jonathan Robie">jonathan.robie</assigned_to>
          <cc>jmdyck</cc>
    
    <cc>josh.spiegel</cc>
          
          <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>116014</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2014-12-08 16:14:15 +0000</bug_when>
    <thetext>Biro D. Botond (botond23@gmail.com) raised the following on public-qt-comments:

Is it expected to evaluate the keyspecifier with a new inner focus?

From semantic equivalance of E?S and E ! ?S one would expect so – in
this case I suggest to mention the postfix lookup in the context
changing expressions in 2.1.2 Dynamic context – context item
definition.

MHK comment:

It appears that the current specification for the binary lookup operator does cause S to be evaluated with a focus based on E. It&apos;s not clear that this is what we intended, and it&apos;s not clear that it has any benefits. On the contrary, it seems to bring back some of the known pitfalls of the focus change in ordinary predicates.

For example, one might expect that

&lt;xsl:for-each select=&quot;1 to 5&quot;&gt;
  &lt;xsl:copy-of select=&quot;$array?(.+1)&quot;/&gt;
&lt;/xsl:for-each&gt;

does the same as 

&lt;xsl:for-each select=&quot;1 to 5&quot;&gt;
  &lt;xsl:copy-of select=&quot;$array(.+1)&quot;/&gt;
&lt;/xsl:for-each&gt;

but as currently specified, this is not the case; it actually raises a type error because &quot;.&quot; is bound to the array.

Unfortunately, changing this makes it difficult to define binary-? in terms of unary-?. A better approach might be to define the unary expression ?X as equivalent to .?X, and to define $A?(E) as equivalent to 

for $a in $A, $e in $E return $a($e)

provided that $a is a map or array (else type error).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116068</commentid>
    <comment_count>1</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2014-12-09 20:29:37 +0000</bug_when>
    <thetext>In today&apos;s call we agreed to change the description to:

for $a in E, $b in S return $a($b)

If $a is not a map or array, a type error is raised.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>121775</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-07-06 08:53:36 +0000</bug_when>
    <thetext>The revised description is inadequate. Consider

$emps?fred

This is not equivalent to

for $e in $emps, $f in fred return $e($f)

Rather, it is equivalent to 

for $e in $emps, $f in &quot;fred&quot; return $e($f)

The equivalence also does not work for wildcards ($emps?*).

I suggest the following:

&lt;quote&gt;
The semantics of a Postfix Lookup expression depend on the form of the KeySpecifier, as follows:

* If the KeySpecifier is an NCName, IntegerLiteral, or Wildcard (&quot;*&quot;), then the expression E?S is equivalent to E!?S. (That is, the semantics of the postfix lookup operator are defined in terms of the unary lookup operator).

* If the KeySpecifier is a ParenthesizedExpr, then the expression E?(S) is equivalent to 

for $e in E, $s in S return $e($s)

Note: the focus for evaluating S is the same as the focus for the PostfixLookup expression itself.
&lt;/quote&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>121869</commentid>
    <comment_count>3</comment_count>
    <who name="Josh Spiegel">josh.spiegel</who>
    <bug_when>2015-07-08 11:48:04 +0000</bug_when>
    <thetext>I agree with Comment 2 but I assume this needs to go back to the WG.  Note, editorial bug 27715 can likely close with this bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122003</commentid>
    <comment_count>4</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2015-07-13 21:37:54 +0000</bug_when>
    <thetext>I put this in the spec, with a change log note stating that this change is not yet approved.  Leaving reopened, discuss at the face-to-face.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122041</commentid>
    <comment_count>5</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2015-07-14 19:53:33 +0000</bug_when>
    <thetext>*** Bug 27715 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122145</commentid>
    <comment_count>6</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2015-07-16 14:28:30 +0000</bug_when>
    <thetext>The WG accepted the solution in the current text.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>