[Bug 2348] [xqueryx] lost parenthesis

http://www.w3.org/Bugs/Public/show_bug.cgi?id=2348

           Summary: [xqueryx]  lost parenthesis
           Product: XPath / XQuery / XSLT
           Version: Last Call drafts
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XQueryX
        AssignedTo: jim.melton@acm.org
        ReportedBy: davidc@nag.co.uk
         QAContact: public-qt-comments@w3.org


The "natural" XqueryX encoding of the Xquery
<a/>/(for $x in 1 return $x)

is translated by the stylesheet to

<a></a>/
 for $x in 1
 return $x

which is a syntax error. As xqx:parenthesizedExpr does not cause () to be added
and (unlike xqx:addOp etc) xqx:filterExpr does not put a () group around its
argument.

To be specific about the xqueryx, it's included at the end of this message.
A workaround would be to use xqx:sequenceExpr instead of xqx:parenthesizedExpr 
as that always translates to () but parenthesizedExpr is more natural here
(and corresponds to the production in the EBNF for this expression).

I accept that this will probably be deferred until the next round, but I wanted
to post it now anyway so it didn't get lost.

I think simplest fix would be to add a template for
xqx:filterExpr/xqx:parenthesizedExpr that adds ().

David


<xqx:module xmlns:xqx="http://www.w3.org/2005/XQueryX">
   <xqx:mainModule>
      <xqx:queryBody>
         <xqx:pathExpr>
            <xqx:stepExpr>
               <xqx:filterExpr>
                  <xqx:elementConstructor>
                     <xqx:tagName>a</xqx:tagName>
                  </xqx:elementConstructor>
               </xqx:filterExpr>
            </xqx:stepExpr>
            <xqx:stepExpr>
               <xqx:filterExpr>
                  <xqx:parenthesizedExpr>
                     <xqx:flworExpr>
                        <xqx:forClause>
                           <xqx:forClauseItem>
                              <xqx:typedVariableBinding>
                                 <xqx:varName>x</xqx:varName>
                              </xqx:typedVariableBinding>
                              <xqx:forExpr>
                                 <xqx:integerConstantExpr>
                                    <xqx:value>1</xqx:value>
                                 </xqx:integerConstantExpr>
                              </xqx:forExpr>
                           </xqx:forClauseItem>
                        </xqx:forClause>
                        <xqx:returnClause>
                           <xqx:pathExpr>
                              <xqx:stepExpr>
                                 <xqx:filterExpr>
                                    <xqx:varRef>
                                       <xqx:name>x</xqx:name>
                                    </xqx:varRef>
                                 </xqx:filterExpr>
                              </xqx:stepExpr>
                           </xqx:pathExpr>
                        </xqx:returnClause>
                     </xqx:flworExpr>
                  </xqx:parenthesizedExpr>
               </xqx:filterExpr>
            </xqx:stepExpr>
         </xqx:pathExpr>
      </xqx:queryBody>
   </xqx:mainModule>
</xqx:module>

Received on Monday, 17 October 2005 22:23:33 UTC