[Bug 26324] New: XQuery 3.0's PostfixExpr is not properly represented in XQueryX 3.0

https://www.w3.org/Bugs/Public/show_bug.cgi?id=26324

            Bug ID: 26324
           Summary: XQuery 3.0's PostfixExpr is not properly represented
                    in XQueryX 3.0
           Product: XPath / XQuery / XSLT
           Version: Recommendation
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: XQueryX 3.0
          Assignee: jim.melton@acm.org
          Reporter: jim.melton@acm.org
        QA Contact: public-qt-comments@w3.org

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'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 "PostfixExpr" in the parse tree. 

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

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

In this case, please note that the <xqx:functionItem> is an
<xqx:integerConstantExpr> (12) followed by <xqx:arguments> (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 "FIXED"?  I presume that
the fix would be to permit XQueryX code that looks something like this:

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

(Note the use of <xqx:postfixExpr>, 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'm still working on it) I can do so with full XQueryX 3.0
compatibility with or without "fixing" this problem in XQueryX 3.0. 

Guidance, please!!

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Sunday, 13 July 2014 22:51:42 UTC