<?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>26324</bug_id>
          
          <creation_ts>2014-07-13 22:51:40 +0000</creation_ts>
          <short_desc>XQuery 3.0&apos;s PostfixExpr is not properly represented in XQueryX 3.0</short_desc>
          <delta_ts>2014-07-14 08:10:50 +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>XQueryX 3.0</component>
          <version>Recommendation</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jim Melton">jim.melton</reporter>
          <assigned_to name="Jim Melton">jim.melton</assigned_to>
          <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>108897</commentid>
    <comment_count>0</comment_count>
    <who name="Jim Melton">jim.melton</who>
    <bug_when>2014-07-13 22:51:40 +0000</bug_when>
    <thetext>In XQuery 3.0, the following expression is apparently valid:
   12(1,2)[3]
and is represented by the following BNF:
   PathExpr ::= ...
              | RelativePathExpr
   RelativePathExpr ::= StepExpr
   StepExpr ::= PostfixExpr | ...
   PostfixExpr ::= PrimaryExpr (Predicate | ArgumentList)*
   PrimaryExpr ::= Literal | ...

(Note: I don&apos;t claim that I understand why anybody would write such an expression, but it is apparently valid.)

The expressions is accepted by our syntax checker and produces the following parse tree:

|START [1:0 - 1:10]
|   QueryList [1:0 - 1:10]
|      Module [1:0 - 1:10]
|         MainModule [1:0 - 1:10]
|            Prolog [1:0 - 0:0]
|            QueryBody [1:0 - 1:10]
|               Expr [1:0 - 1:10]
|                  PathExpr [1:0 - 1:10]
|                     PostfixExpr [1:0 - 1:10]
|                        IntegerLiteral 12 [2:1 - 1:2]
|                        ArgumentList [2:1 - 1:7]
|                           Argument [2:3 - 1:4]
|                              PathExpr [2:3 - 1:4]
|                                 PostfixExpr [2:3 - 1:4]
|                                    IntegerLiteral 1 [2:4 - 1:4]
|                           Argument [2:5 - 1:6]
|                              PathExpr [2:5 - 1:6]
|                                 PostfixExpr [2:5 - 1:6]
|                                    IntegerLiteral 2 [2:6 - 1:6]
|                        Predicate [2:7 - 1:10]
|                           Expr [2:8 - 1:9]
|                              PathExpr [2:8 - 1:9]
|                                 PostfixExpr [2:8 - 1:9]
|                                    IntegerLiteral 3 [2:9 - 1:9]

Note particularly the appearance of &quot;PostfixExpr&quot; in the parse tree. 

However, in the XQueryX translation produced by the syntax checker, that same expression transforms to:

&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;xqx:module xmlns:xqx=&quot;http://www.w3.org/2005/XQueryX&quot;
            xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
            xsi:schemaLocation=&quot;http://www.w3.org/2005/XQueryX
                                http://www.w3.org/2005/XQueryX/xqueryx.xsd&quot;&gt;
  &lt;xqx:mainModule&gt;
    &lt;xqx:queryBody&gt;
      &lt;xqx:pathExpr&gt;
        &lt;xqx:stepExpr&gt;
          &lt;xqx:filterExpr&gt;
            &lt;xqx:dynamicFunctionInvocationExpr&gt;
              &lt;xqx:functionItem&gt;
                &lt;xqx:integerConstantExpr&gt;
                  &lt;xqx:value&gt;12&lt;/xqx:value&gt;
                &lt;/xqx:integerConstantExpr&gt;
              &lt;/xqx:functionItem&gt;
              &lt;xqx:arguments&gt;
                &lt;xqx:integerConstantExpr&gt;
                  &lt;xqx:value&gt;1&lt;/xqx:value&gt;
                &lt;/xqx:integerConstantExpr&gt;
                &lt;xqx:integerConstantExpr&gt;
                  &lt;xqx:value&gt;2&lt;/xqx:value&gt;
                &lt;/xqx:integerConstantExpr&gt;
              &lt;/xqx:arguments&gt;
            &lt;/xqx:dynamicFunctionInvocationExpr&gt;
          &lt;/xqx:filterExpr&gt;
          &lt;xqx:predicates&gt;
            &lt;xqx:integerConstantExpr&gt;
              &lt;xqx:value&gt;3&lt;/xqx:value&gt;
            &lt;/xqx:integerConstantExpr&gt;
          &lt;/xqx:predicates&gt;
        &lt;/xqx:stepExpr&gt;
      &lt;/xqx:pathExpr&gt;
    &lt;/xqx:queryBody&gt;
  &lt;/xqx:mainModule&gt;
&lt;/xqx:module&gt;

In this case, please note that the &lt;xqx:functionItem&gt; is an &lt;xqx:integerConstantExpr&gt; (12) followed by &lt;xqx:arguments&gt; (1 and 2).

The XQueryX 3.0 stylesheet would (does) transform to the original expression:
   12(1,2)[3]
But that is more an accident than a planned chain of events. 

DOES THE XQUERYX COMMUNITY BELIEVE THAT THIS SHOULD BE &quot;FIXED&quot;?  I presume that the fix would be to permit XQueryX code that looks something like this:

&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;xqx:module xmlns:xqx=&quot;http://www.w3.org/2005/XQueryX&quot;
            xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
            xsi:schemaLocation=&quot;http://www.w3.org/2005/XQueryX
                                http://www.w3.org/2005/XQueryX/xqueryx.xsd&quot;&gt;
  &lt;xqx:mainModule&gt;
    &lt;xqx:queryBody&gt;
      &lt;xqx:pathExpr&gt;
        &lt;xqx:stepExpr&gt;
          &lt;xqx:postfixExpr&gt;
            &lt;xqx:integerConstantExpr&gt;
              &lt;xqx:value&gt;12&lt;/xqx:value&gt;
            &lt;/xqx:integerConstantExpr&gt;
            &lt;xqx:arguments&gt;
              &lt;xqx:integerConstantExpr&gt;
                &lt;xqx:value&gt;1&lt;/xqx:value&gt;
              &lt;/xqx:integerConstantExpr&gt;
              &lt;xqx:integerConstantExpr&gt;
                &lt;xqx:value&gt;2&lt;/xqx:value&gt;
              &lt;/xqx:integerConstantExpr&gt;
            &lt;/xqx:arguments&gt;
          &lt;/xqx:postfixExpr&gt;
          &lt;xqx:predicates&gt;
            &lt;xqx:integerConstantExpr&gt;
              &lt;xqx:value&gt;3&lt;/xqx:value&gt;
            &lt;/xqx:integerConstantExpr&gt;
          &lt;/xqx:predicates&gt;
        &lt;/xqx:stepExpr&gt;
      &lt;/xqx:pathExpr&gt;
    &lt;/xqx:queryBody&gt;
  &lt;/xqx:mainModule&gt;
&lt;/xqx:module&gt;

(Note the use of &lt;xqx:postfixExpr&gt;, which does not appear at all in the XQueryX 3.0 schema or stylesheet.)

I believe that I have no choice but to make this kind of fix in XQueryX 3.1 because of the new alternatives in the production for PostfixExpr, and I *think* (I&apos;m still working on it) I can do so with full XQueryX 3.0 compatibility with or without &quot;fixing&quot; this problem in XQueryX 3.0. 

Guidance, please!!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108898</commentid>
    <comment_count>1</comment_count>
    <who name="Jim Melton">jim.melton</who>
    <bug_when>2014-07-13 23:31:31 +0000</bug_when>
    <thetext>Upon additional consideration, especially after re-reading XQuery 3.0, section 3.2 &quot;Postfix Expressions&quot;, last paragraph:

   An expression (other than a raw EQName) followed by an argument list in parentheses (that is, E1(E2, E3, ...)) is referred to as a dynamic function call. Its effect is to evaluate E1 to obtain a function, and then call that function, with E2, E3, ... as arguments. Dynamic function calls are described in 3.2.2 Dynamic Function Call.

I have concluded that the specific case of 12(1,2) is a useless artifact of allowing far more useful expressions such as $x(1,2) (which is a DynamicFunctionInvocation). 

The cost in &quot;fixing&quot; the case of 12(1,2) to be a (useless) Postfix Expression instead of a Dynamic Function Invocation is in no way worth the effort, particularly as it doesn&apos;t actually change any results. 

I am therefore marking this bug RESOLVED/INVALID and then marking it CLOSED. 

Sorry for the interruption.  Please carry on.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108902</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2014-07-14 08:10:50 +0000</bug_when>
    <thetext>The expression 12(1) is syntactically valid but is always a type error (rather like the expression (&quot;London&quot;+1). So you&apos;re really asking a policy question: should XQueryX be able to represent every syntactically-valid XQuery expression, or should it only be required to represent expressions that have no static errors. (And then the sub-question, are type errors regarded as static errors for this purpose?)</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>