<?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>16197</bug_id>
          
          <creation_ts>2012-03-02 12:48:48 +0000</creation_ts>
          <short_desc>[XP30] Precedence of the Simple Map Operator</short_desc>
          <delta_ts>2014-09-16 18:47:09 +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.0</component>
          <version>Last Call 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="John Snelson">john.snelson</reporter>
          <assigned_to name="Jonathan Robie">jonathan.robie</assigned_to>
          <cc>jim.melton</cc>
    
    <cc>john.snelson</cc>
    
    <cc>mike</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>64902</commentid>
    <comment_count>0</comment_count>
    <who name="John Snelson">john.snelson</who>
    <bug_when>2012-03-02 12:48:48 +0000</bug_when>
    <thetext>I find the precedence of the simple map operator a little surprising in general use. For instance, this is valid syntax:

foo ! bar

But this is not valid syntax:

foo ! /bar

I think we should change the grammar to make this expression valid, as follows:

ValueExpr ::= ValidateExpr | SimpleMapExpr | ExtensionExpr

SimpleMapExpr ::= PathExpr (&quot;!&quot; PathExpr)*

PathExpr ::= (&quot;/&quot; RelativePathExpr?)
           | (&quot;//&quot; RelativePathExpr)
           | RelativePathExpr
RelativePathExpr ::= StepExpr ((&quot;/&quot; | &quot;//&quot;) StepExpr)*</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>67973</commentid>
    <comment_count>1</comment_count>
    <who name="John Snelson">john.snelson</who>
    <bug_when>2012-05-21 16:29:58 +0000</bug_when>
    <thetext>Actually this change would also affect the associativity of &quot;!&quot; with respect to &quot;/&quot;. The current grammar has &quot;/&quot; and &quot;!&quot; at the same precedence, and left associative. Here&apos;s an example where that makes a difference:

let $doc := document { &lt;a&gt;&lt;b&gt;1&lt;/b&gt;&lt;a&gt;&lt;b&gt;2&lt;/b&gt;&lt;/a&gt;&lt;/a&gt;,&lt;a&gt;&lt;b&gt;3&lt;/b&gt;&lt;/a&gt; }
return
  $doc // a ! descendant::b / text()

This is implicitly parameterized like this:

(($doc // a) ! descendant::b) / text()    -&gt; (&quot;1&quot;, &quot;2&quot;, &quot;3&quot;)


However my proposed change parameterizes it like this:

($doc // a) ! (descendant::b / text())    -&gt; (&quot;1&quot;, &quot;2&quot;, &quot;2&quot;, &quot;3&quot;)

I believe that by using the &quot;!&quot; operator, the user has explicitly chosen not to have document ordering and duplicate removal applied to the result sequence. The latter precedence and associativity more closely matches this expectation.

Other more minor differences with my proposed change include the one in the bug description above, as well as allowing the following currently illegal syntax:

/ ! document-uri(.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>67982</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2012-05-21 23:27:19 +0000</bug_when>
    <thetext>I think I&apos;m persuaded. It seems that (apart from a syntactic interaction with edge cases involving lone-slash), the only impact is on expressions that use &quot;/&quot; to the right of &quot;!&quot;. And it&apos;s hard to construct realistic examples where (under the current rules) such a use of &quot;!&quot; is usefully different from &quot;/&quot;, given that the lhs of &quot;/&quot; has to be nodes, and the &quot;/&quot; does any document-ordering that the &quot;!&quot; might otherwise have prevented. So the current precedence rules don&apos;t allow you to do anything very useful, wheras the proposed precedence rules allow expressions such as

$page//@href ! doc(.)//title

where the fact that &quot;!&quot; doesn&apos;t do document-ordering is potentially useful.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>68988</commentid>
    <comment_count>3</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2012-06-12 15:28:07 +0000</bug_when>
    <thetext>I&apos;m persuaded also. This example from Comment 1 was particularly convincing:

$doc // a ! descendant::b / text()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>68996</commentid>
    <comment_count>4</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2012-06-12 15:58:57 +0000</bug_when>
    <thetext>The Working Group agrees. We will make this change.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>