<?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>5028</bug_id>
          
          <creation_ts>2007-09-10 19:16:21 +0000</creation_ts>
          <short_desc>[UPD] stylesheet needs to generate more parenthesis</short_desc>
          <delta_ts>2007-09-25 14:29:36 +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>Update Facility</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="Andrew Eisenberg">andrew.eisenberg</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>16435</commentid>
    <comment_count>0</comment_count>
    <who name="Andrew Eisenberg">andrew.eisenberg</who>
    <bug_when>2007-09-10 19:16:21 +0000</bug_when>
    <thetext>I believe that the stylesheet shown in E.2 Stylesheet and provided in http://www.w3.org/2007/xquery-update-10/xquery-update-10-xqueryx.xsl must be changed to generate parenthesis around the new updating and non-updating expressions.


The following query will soon appear in the XQuery Update Test Suite:

(: Name: id-other-expr-031 :)
(: Description: Evaluates usage of an non updating expression (transform) as part of a sequence expression (except operator). :)

(: insert-start :)
declare variable $input-context external;
(: insert-end :)

let $var1 := $input-context/works[1]/employee[1]
let $var2 := $input-context/works[1]/employee[2]
return
   (copy $newVar := $var1 modify delete node $newVar/hours[1] return $newVar)
   except
   (copy $newVar := $var2 modify delete node $newVar/hours[1] return $newVar)


The XQueryX that corresponds to this query contains the following fragment:

        &lt;xqx:returnClause&gt;
          &lt;xqx:exceptOp&gt;
            &lt;xqx:firstOperand&gt;
              &lt;xqxuf:transformExpr&gt;
              ...
              &lt;/xqxuf:transformExpr&gt;
            &lt;/xqx:firstOperand&gt;
            &lt;xqx:secondOperand&gt;
              &lt;xqxuf:transformExpr&gt;
              ...
              &lt;/xqxuf:transformExpr&gt;
            &lt;/xqx:secondOperand&gt;
          &lt;/xqx:exceptOp&gt;
        &lt;/xqx:returnClause&gt;


This correctly reflects the return of the except with two operands, each of which is a transform expression. I&apos;ll place the complete XQueryX document at the end of this report.


The XQuery that is generated from this XQueryX is:

 declare variable $input-context  external ;

( let $var1:=$input-context/child::works[1]/child::employee[1]
 let $var2:=$input-context/child::works[1]/child::employee[2]
 return (copy $newVar := $var1
  modify delete nodes $newVar/child::hours[1]
  return $newVar except copy $newVar := $var2
  modify delete nodes $newVar/child::hours[1]
  return $newVar)
)


This query raises a parse error:

   Encountered &quot;$&quot; at line 7, column 30.
   Was expecting one of: ...



Fyi, I raised a similar issue for XQueryX some time ago in Bug #3333.




The complete XQueryX document that I referred to earlier is:

&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;xqx:module xmlns:xqx=&quot;http://www.w3.org/2005/XQueryX&quot;
            xmlns:xqxuf=&quot;http://www.w3.org/2007/xquery-update-10&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
                                http://www.w3.org/2007/xquery-update-10
                                http://www.w3.org/2007/xquery-update-10/xquery-update-10-xqueryx.xsd&quot;&gt;
  &lt;xqx:mainModule&gt;
    &lt;xqx:prolog&gt;
      &lt;xqx:varDecl&gt;
        &lt;xqx:varName&gt;input-context&lt;/xqx:varName&gt;
        &lt;xqx:external/&gt;
      &lt;/xqx:varDecl&gt;
    &lt;/xqx:prolog&gt;
    &lt;xqx:queryBody&gt;
      &lt;xqx:flworExpr&gt;
        &lt;xqx:letClause&gt;
          &lt;xqx:letClauseItem&gt;
            &lt;xqx:typedVariableBinding&gt;
              &lt;xqx:varName&gt;var1&lt;/xqx:varName&gt;
            &lt;/xqx:typedVariableBinding&gt;
            &lt;xqx:letExpr&gt;
              &lt;xqx:pathExpr&gt;
                &lt;xqx:stepExpr&gt;
                  &lt;xqx:filterExpr&gt;
                    &lt;xqx:varRef&gt;
                      &lt;xqx:name&gt;input-context&lt;/xqx:name&gt;
                    &lt;/xqx:varRef&gt;
                  &lt;/xqx:filterExpr&gt;
                &lt;/xqx:stepExpr&gt;
                &lt;xqx:stepExpr&gt;
                  &lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
                  &lt;xqx:nameTest&gt;works&lt;/xqx:nameTest&gt;
                  &lt;xqx:predicates&gt;
                    &lt;xqx:integerConstantExpr&gt;
                      &lt;xqx:value&gt;1&lt;/xqx:value&gt;
                    &lt;/xqx:integerConstantExpr&gt;
                  &lt;/xqx:predicates&gt;
                &lt;/xqx:stepExpr&gt;
                &lt;xqx:stepExpr&gt;
                  &lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
                  &lt;xqx:nameTest&gt;employee&lt;/xqx:nameTest&gt;
                  &lt;xqx:predicates&gt;
                    &lt;xqx:integerConstantExpr&gt;
                      &lt;xqx:value&gt;1&lt;/xqx:value&gt;
                    &lt;/xqx:integerConstantExpr&gt;
                  &lt;/xqx:predicates&gt;
                &lt;/xqx:stepExpr&gt;
              &lt;/xqx:pathExpr&gt;
            &lt;/xqx:letExpr&gt;
          &lt;/xqx:letClauseItem&gt;
        &lt;/xqx:letClause&gt;
        &lt;xqx:letClause&gt;
          &lt;xqx:letClauseItem&gt;
            &lt;xqx:typedVariableBinding&gt;
              &lt;xqx:varName&gt;var2&lt;/xqx:varName&gt;
            &lt;/xqx:typedVariableBinding&gt;
            &lt;xqx:letExpr&gt;
              &lt;xqx:pathExpr&gt;
                &lt;xqx:stepExpr&gt;
                  &lt;xqx:filterExpr&gt;
                    &lt;xqx:varRef&gt;
                      &lt;xqx:name&gt;input-context&lt;/xqx:name&gt;
                    &lt;/xqx:varRef&gt;
                  &lt;/xqx:filterExpr&gt;
                &lt;/xqx:stepExpr&gt;
                &lt;xqx:stepExpr&gt;
                  &lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
                  &lt;xqx:nameTest&gt;works&lt;/xqx:nameTest&gt;
                  &lt;xqx:predicates&gt;
                    &lt;xqx:integerConstantExpr&gt;
                      &lt;xqx:value&gt;1&lt;/xqx:value&gt;
                    &lt;/xqx:integerConstantExpr&gt;
                  &lt;/xqx:predicates&gt;
                &lt;/xqx:stepExpr&gt;
                &lt;xqx:stepExpr&gt;
                  &lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
                  &lt;xqx:nameTest&gt;employee&lt;/xqx:nameTest&gt;
                  &lt;xqx:predicates&gt;
                    &lt;xqx:integerConstantExpr&gt;
                      &lt;xqx:value&gt;2&lt;/xqx:value&gt;
                    &lt;/xqx:integerConstantExpr&gt;
                  &lt;/xqx:predicates&gt;
                &lt;/xqx:stepExpr&gt;
              &lt;/xqx:pathExpr&gt;
            &lt;/xqx:letExpr&gt;
          &lt;/xqx:letClauseItem&gt;
        &lt;/xqx:letClause&gt;
        &lt;xqx:returnClause&gt;
          &lt;xqx:exceptOp&gt;
            &lt;xqx:firstOperand&gt;
              &lt;xqxuf:transformExpr&gt;
                &lt;xqxuf:transformCopies&gt;
                  &lt;xqxuf:transformCopy&gt;
                    &lt;xqx:varRef&gt;
                      &lt;xqx:name&gt;newVar&lt;/xqx:name&gt;
                    &lt;/xqx:varRef&gt;
                    &lt;xqxuf:copySource&gt;
                      &lt;xqx:varRef&gt;
                        &lt;xqx:name&gt;var1&lt;/xqx:name&gt;
                      &lt;/xqx:varRef&gt;
                    &lt;/xqxuf:copySource&gt;
                  &lt;/xqxuf:transformCopy&gt;
                &lt;/xqxuf:transformCopies&gt;
                &lt;xqxuf:modifyExpr&gt;
                  &lt;xqxuf:deleteExpr&gt;
                    &lt;xqxuf:targetExpr&gt;
                      &lt;xqx:pathExpr&gt;
                        &lt;xqx:stepExpr&gt;
                          &lt;xqx:filterExpr&gt;
                            &lt;xqx:varRef&gt;
                              &lt;xqx:name&gt;newVar&lt;/xqx:name&gt;
                            &lt;/xqx:varRef&gt;
                          &lt;/xqx:filterExpr&gt;
                        &lt;/xqx:stepExpr&gt;
                        &lt;xqx:stepExpr&gt;
                          &lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
                          &lt;xqx:nameTest&gt;hours&lt;/xqx:nameTest&gt;
                          &lt;xqx:predicates&gt;
                            &lt;xqx:integerConstantExpr&gt;
                              &lt;xqx:value&gt;1&lt;/xqx:value&gt;
                            &lt;/xqx:integerConstantExpr&gt;
                          &lt;/xqx:predicates&gt;
                        &lt;/xqx:stepExpr&gt;
                      &lt;/xqx:pathExpr&gt;
                    &lt;/xqxuf:targetExpr&gt;
                  &lt;/xqxuf:deleteExpr&gt;
                &lt;/xqxuf:modifyExpr&gt;
                &lt;xqxuf:returnExpr&gt;
                  &lt;xqx:varRef&gt;
                    &lt;xqx:name&gt;newVar&lt;/xqx:name&gt;
                  &lt;/xqx:varRef&gt;
                &lt;/xqxuf:returnExpr&gt;
              &lt;/xqxuf:transformExpr&gt;
            &lt;/xqx:firstOperand&gt;
            &lt;xqx:secondOperand&gt;
              &lt;xqxuf:transformExpr&gt;
                &lt;xqxuf:transformCopies&gt;
                  &lt;xqxuf:transformCopy&gt;
                    &lt;xqx:varRef&gt;
                      &lt;xqx:name&gt;newVar&lt;/xqx:name&gt;
                    &lt;/xqx:varRef&gt;
                    &lt;xqxuf:copySource&gt;
                      &lt;xqx:varRef&gt;
                        &lt;xqx:name&gt;var2&lt;/xqx:name&gt;
                      &lt;/xqx:varRef&gt;
                    &lt;/xqxuf:copySource&gt;
                  &lt;/xqxuf:transformCopy&gt;
                &lt;/xqxuf:transformCopies&gt;
                &lt;xqxuf:modifyExpr&gt;
                  &lt;xqxuf:deleteExpr&gt;
                    &lt;xqxuf:targetExpr&gt;
                      &lt;xqx:pathExpr&gt;
                        &lt;xqx:stepExpr&gt;
                          &lt;xqx:filterExpr&gt;
                            &lt;xqx:varRef&gt;
                              &lt;xqx:name&gt;newVar&lt;/xqx:name&gt;
                            &lt;/xqx:varRef&gt;
                          &lt;/xqx:filterExpr&gt;
                        &lt;/xqx:stepExpr&gt;
                        &lt;xqx:stepExpr&gt;
                          &lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
                          &lt;xqx:nameTest&gt;hours&lt;/xqx:nameTest&gt;
                          &lt;xqx:predicates&gt;
                            &lt;xqx:integerConstantExpr&gt;
                              &lt;xqx:value&gt;1&lt;/xqx:value&gt;
                            &lt;/xqx:integerConstantExpr&gt;
                          &lt;/xqx:predicates&gt;
                        &lt;/xqx:stepExpr&gt;
                      &lt;/xqx:pathExpr&gt;
                    &lt;/xqxuf:targetExpr&gt;
                  &lt;/xqxuf:deleteExpr&gt;
                &lt;/xqxuf:modifyExpr&gt;
                &lt;xqxuf:returnExpr&gt;
                  &lt;xqx:varRef&gt;
                    &lt;xqx:name&gt;newVar&lt;/xqx:name&gt;
                  &lt;/xqx:varRef&gt;
                &lt;/xqxuf:returnExpr&gt;
              &lt;/xqxuf:transformExpr&gt;
            &lt;/xqx:secondOperand&gt;
          &lt;/xqx:exceptOp&gt;
        &lt;/xqx:returnClause&gt;
      &lt;/xqx:flworExpr&gt;
    &lt;/xqx:queryBody&gt;
  &lt;/xqx:mainModule&gt;
&lt;/xqx:module&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>16535</commentid>
    <comment_count>1</comment_count>
    <who name="Jim Melton">jim.melton</who>
    <bug_when>2007-09-13 19:36:43 +0000</bug_when>
    <thetext>Thanks for finding this problem.  I have modified the Update Facility&apos;s XQueryX stylesheet to surround all updating expressions with parentheses.  Because this specific bug has been resolved (tested by using the modified stylesheet to transform the XQueryX example you provided into XQuery, then parsing that XQuery using the XQuery Update parser applet in member-only CVS), I am marking this bug FIXED.  Please mark it CLOSED if you agree that the revised stylesheet checked into member-only CVS at http://www.w3.org/XML/Group/xsl-query-specs/xquery-updates/src/xquery-update-10-xqueryx.xsl fixes this bug. 

I would be grateful for continued testing of the Update Facility XQueryX schema and stylesheet. </thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>