[Bug 5028] [UPD] stylesheet needs to generate more parenthesis

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

           Summary: [UPD] stylesheet needs to generate more parenthesis
           Product: XPath / XQuery / XSLT
           Version: Last Call drafts
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Update Facility
        AssignedTo: jim.melton@acm.org
        ReportedBy: andrew.eisenberg@us.ibm.com
         QAContact: public-qt-comments@w3.org


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:

        <xqx:returnClause>
          <xqx:exceptOp>
            <xqx:firstOperand>
              <xqxuf:transformExpr>
              ...
              </xqxuf:transformExpr>
            </xqx:firstOperand>
            <xqx:secondOperand>
              <xqxuf:transformExpr>
              ...
              </xqxuf:transformExpr>
            </xqx:secondOperand>
          </xqx:exceptOp>
        </xqx:returnClause>


This correctly reflects the return of the except with two operands, each of
which is a transform expression. I'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 "$" 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:

<?xml version="1.0"?>
<xqx:module xmlns:xqx="http://www.w3.org/2005/XQueryX"
            xmlns:xqxuf="http://www.w3.org/2007/xquery-update-10"
            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
                                http://www.w3.org/2007/xquery-update-10
                               
http://www.w3.org/2007/xquery-update-10/xquery-update-10-xqueryx.xsd">
  <xqx:mainModule>
    <xqx:prolog>
      <xqx:varDecl>
        <xqx:varName>input-context</xqx:varName>
        <xqx:external/>
      </xqx:varDecl>
    </xqx:prolog>
    <xqx:queryBody>
      <xqx:flworExpr>
        <xqx:letClause>
          <xqx:letClauseItem>
            <xqx:typedVariableBinding>
              <xqx:varName>var1</xqx:varName>
            </xqx:typedVariableBinding>
            <xqx:letExpr>
              <xqx:pathExpr>
                <xqx:stepExpr>
                  <xqx:filterExpr>
                    <xqx:varRef>
                      <xqx:name>input-context</xqx:name>
                    </xqx:varRef>
                  </xqx:filterExpr>
                </xqx:stepExpr>
                <xqx:stepExpr>
                  <xqx:xpathAxis>child</xqx:xpathAxis>
                  <xqx:nameTest>works</xqx:nameTest>
                  <xqx:predicates>
                    <xqx:integerConstantExpr>
                      <xqx:value>1</xqx:value>
                    </xqx:integerConstantExpr>
                  </xqx:predicates>
                </xqx:stepExpr>
                <xqx:stepExpr>
                  <xqx:xpathAxis>child</xqx:xpathAxis>
                  <xqx:nameTest>employee</xqx:nameTest>
                  <xqx:predicates>
                    <xqx:integerConstantExpr>
                      <xqx:value>1</xqx:value>
                    </xqx:integerConstantExpr>
                  </xqx:predicates>
                </xqx:stepExpr>
              </xqx:pathExpr>
            </xqx:letExpr>
          </xqx:letClauseItem>
        </xqx:letClause>
        <xqx:letClause>
          <xqx:letClauseItem>
            <xqx:typedVariableBinding>
              <xqx:varName>var2</xqx:varName>
            </xqx:typedVariableBinding>
            <xqx:letExpr>
              <xqx:pathExpr>
                <xqx:stepExpr>
                  <xqx:filterExpr>
                    <xqx:varRef>
                      <xqx:name>input-context</xqx:name>
                    </xqx:varRef>
                  </xqx:filterExpr>
                </xqx:stepExpr>
                <xqx:stepExpr>
                  <xqx:xpathAxis>child</xqx:xpathAxis>
                  <xqx:nameTest>works</xqx:nameTest>
                  <xqx:predicates>
                    <xqx:integerConstantExpr>
                      <xqx:value>1</xqx:value>
                    </xqx:integerConstantExpr>
                  </xqx:predicates>
                </xqx:stepExpr>
                <xqx:stepExpr>
                  <xqx:xpathAxis>child</xqx:xpathAxis>
                  <xqx:nameTest>employee</xqx:nameTest>
                  <xqx:predicates>
                    <xqx:integerConstantExpr>
                      <xqx:value>2</xqx:value>
                    </xqx:integerConstantExpr>
                  </xqx:predicates>
                </xqx:stepExpr>
              </xqx:pathExpr>
            </xqx:letExpr>
          </xqx:letClauseItem>
        </xqx:letClause>
        <xqx:returnClause>
          <xqx:exceptOp>
            <xqx:firstOperand>
              <xqxuf:transformExpr>
                <xqxuf:transformCopies>
                  <xqxuf:transformCopy>
                    <xqx:varRef>
                      <xqx:name>newVar</xqx:name>
                    </xqx:varRef>
                    <xqxuf:copySource>
                      <xqx:varRef>
                        <xqx:name>var1</xqx:name>
                      </xqx:varRef>
                    </xqxuf:copySource>
                  </xqxuf:transformCopy>
                </xqxuf:transformCopies>
                <xqxuf:modifyExpr>
                  <xqxuf:deleteExpr>
                    <xqxuf:targetExpr>
                      <xqx:pathExpr>
                        <xqx:stepExpr>
                          <xqx:filterExpr>
                            <xqx:varRef>
                              <xqx:name>newVar</xqx:name>
                            </xqx:varRef>
                          </xqx:filterExpr>
                        </xqx:stepExpr>
                        <xqx:stepExpr>
                          <xqx:xpathAxis>child</xqx:xpathAxis>
                          <xqx:nameTest>hours</xqx:nameTest>
                          <xqx:predicates>
                            <xqx:integerConstantExpr>
                              <xqx:value>1</xqx:value>
                            </xqx:integerConstantExpr>
                          </xqx:predicates>
                        </xqx:stepExpr>
                      </xqx:pathExpr>
                    </xqxuf:targetExpr>
                  </xqxuf:deleteExpr>
                </xqxuf:modifyExpr>
                <xqxuf:returnExpr>
                  <xqx:varRef>
                    <xqx:name>newVar</xqx:name>
                  </xqx:varRef>
                </xqxuf:returnExpr>
              </xqxuf:transformExpr>
            </xqx:firstOperand>
            <xqx:secondOperand>
              <xqxuf:transformExpr>
                <xqxuf:transformCopies>
                  <xqxuf:transformCopy>
                    <xqx:varRef>
                      <xqx:name>newVar</xqx:name>
                    </xqx:varRef>
                    <xqxuf:copySource>
                      <xqx:varRef>
                        <xqx:name>var2</xqx:name>
                      </xqx:varRef>
                    </xqxuf:copySource>
                  </xqxuf:transformCopy>
                </xqxuf:transformCopies>
                <xqxuf:modifyExpr>
                  <xqxuf:deleteExpr>
                    <xqxuf:targetExpr>
                      <xqx:pathExpr>
                        <xqx:stepExpr>
                          <xqx:filterExpr>
                            <xqx:varRef>
                              <xqx:name>newVar</xqx:name>
                            </xqx:varRef>
                          </xqx:filterExpr>
                        </xqx:stepExpr>
                        <xqx:stepExpr>
                          <xqx:xpathAxis>child</xqx:xpathAxis>
                          <xqx:nameTest>hours</xqx:nameTest>
                          <xqx:predicates>
                            <xqx:integerConstantExpr>
                              <xqx:value>1</xqx:value>
                            </xqx:integerConstantExpr>
                          </xqx:predicates>
                        </xqx:stepExpr>
                      </xqx:pathExpr>
                    </xqxuf:targetExpr>
                  </xqxuf:deleteExpr>
                </xqxuf:modifyExpr>
                <xqxuf:returnExpr>
                  <xqx:varRef>
                    <xqx:name>newVar</xqx:name>
                  </xqx:varRef>
                </xqxuf:returnExpr>
              </xqxuf:transformExpr>
            </xqx:secondOperand>
          </xqx:exceptOp>
        </xqx:returnClause>
      </xqx:flworExpr>
    </xqx:queryBody>
  </xqx:mainModule>
</xqx:module>

Received on Monday, 10 September 2007 19:16:36 UTC