<?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>2348</bug_id>
          
          <creation_ts>2005-10-17 22:23:27 +0000</creation_ts>
          <short_desc>[xqueryx]  lost parenthesis</short_desc>
          <delta_ts>2005-10-21 16:05:44 +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 1.0</component>
          <version>Last Call drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</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="David Carlisle">davidc</reporter>
          <assigned_to name="Jim Melton">jim.melton</assigned_to>
          
          
          <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>6712</commentid>
    <comment_count>0</comment_count>
    <who name="David Carlisle">davidc</who>
    <bug_when>2005-10-17 22:23:29 +0000</bug_when>
    <thetext>The &quot;natural&quot; XqueryX encoding of the Xquery
&lt;a/&gt;/(for $x in 1 return $x)

is translated by the stylesheet to

&lt;a&gt;&lt;/a&gt;/
 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&apos;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&apos;t get lost.

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

David


&lt;xqx:module xmlns:xqx=&quot;http://www.w3.org/2005/XQueryX&quot;&gt;
   &lt;xqx:mainModule&gt;
      &lt;xqx:queryBody&gt;
         &lt;xqx:pathExpr&gt;
            &lt;xqx:stepExpr&gt;
               &lt;xqx:filterExpr&gt;
                  &lt;xqx:elementConstructor&gt;
                     &lt;xqx:tagName&gt;a&lt;/xqx:tagName&gt;
                  &lt;/xqx:elementConstructor&gt;
               &lt;/xqx:filterExpr&gt;
            &lt;/xqx:stepExpr&gt;
            &lt;xqx:stepExpr&gt;
               &lt;xqx:filterExpr&gt;
                  &lt;xqx:parenthesizedExpr&gt;
                     &lt;xqx:flworExpr&gt;
                        &lt;xqx:forClause&gt;
                           &lt;xqx:forClauseItem&gt;
                              &lt;xqx:typedVariableBinding&gt;
                                 &lt;xqx:varName&gt;x&lt;/xqx:varName&gt;
                              &lt;/xqx:typedVariableBinding&gt;
                              &lt;xqx:forExpr&gt;
                                 &lt;xqx:integerConstantExpr&gt;
                                    &lt;xqx:value&gt;1&lt;/xqx:value&gt;
                                 &lt;/xqx:integerConstantExpr&gt;
                              &lt;/xqx:forExpr&gt;
                           &lt;/xqx:forClauseItem&gt;
                        &lt;/xqx:forClause&gt;
                        &lt;xqx:returnClause&gt;
                           &lt;xqx:pathExpr&gt;
                              &lt;xqx:stepExpr&gt;
                                 &lt;xqx:filterExpr&gt;
                                    &lt;xqx:varRef&gt;
                                       &lt;xqx:name&gt;x&lt;/xqx:name&gt;
                                    &lt;/xqx:varRef&gt;
                                 &lt;/xqx:filterExpr&gt;
                              &lt;/xqx:stepExpr&gt;
                           &lt;/xqx:pathExpr&gt;
                        &lt;/xqx:returnClause&gt;
                     &lt;/xqx:flworExpr&gt;
                  &lt;/xqx:parenthesizedExpr&gt;
               &lt;/xqx:filterExpr&gt;
            &lt;/xqx:stepExpr&gt;
         &lt;/xqx:pathExpr&gt;
      &lt;/xqx:queryBody&gt;
   &lt;/xqx:mainModule&gt;
&lt;/xqx:module&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>6837</commentid>
    <comment_count>1</comment_count>
    <who name="Jim Melton">jim.melton</who>
    <bug_when>2005-10-21 03:44:27 +0000</bug_when>
    <thetext>Thanks once again for your careful reviews.  We have made the change that you
suggested -- to put parens around parenthesized expressions. 

If you agree with this action, please change the status of this bug to CLOSED. </thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>6838</commentid>
    <comment_count>2</comment_count>
    <who name="David Carlisle">davidc</who>
    <bug_when>2005-10-21 10:53:29 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; Thanks once again for your careful reviews.  We have made the change that you
&gt; suggested -- to put parens around parenthesized expressions. 
&gt; 
&gt; If you agree with this action, please change the status of this bug to CLOSED. 

I&apos;m closing the report but could you say (here or in mail) whether you are
adding it to all xqx:parenthesizedExpr or just xqx:filterExpr/xqx:parenthesizedExpr
(So I can change my local copy) either way is fine by me.
If you do all xqx:parenthesizedExpr you&apos;ll get a lot of doubled parenthesis when
translating infix expressions as the infix template fully parenthesises its
arguments anyway. That&apos;s safe if a bit untidy. If you just do it in
filterexpressions then there may be other places that need doing as well (I
haven&apos;t done a full check)


 David</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>6857</commentid>
    <comment_count>3</comment_count>
    <who name="Jim Melton">jim.melton</who>
    <bug_when>2005-10-21 16:05:44 +0000</bug_when>
    <thetext>Apologies for failing to provide the solution in my earlier response.  The
solution chosen was to add the parens to all instances of xqx:parenthesizedExpr.
As you observe, that will sometimes be untidy (polite word for &quot;ugly&quot;), but at
least it is safe and covers all possibilities.  Had it been limited to only
xqx:filterExpr/xqx:parenthesizedExpr, there would perhaps be other
xqx:???/xqx:parenthesizedExpr that should have been covered.  The broad, but
less elegant, solution seemed preferable at this stage of processing. </thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>