[XQueryX 3.0] defines an XML representation of [XQuery 3.0: An XML Query Language]. [XQuery Update Facility 3.0 Requirements and Use Cases] states "The syntax for updates MAY have more than one syntax binding. One syntax MUST be convenient for humans to read and write. One syntax MUST be expressed in XML in a way that reflects the underlying structure of the operations." This appendix specifies an XML Schema that defines the XML representation of XQuery Update Facility 3.0 by representing the abstract syntax found in [A EBNF for XQuery 3.0 Grammar with Update extensions]. This XML representation for XQuery Update Facility 3.0 integrates with the XML representation for XQuery 3.0.
The XML Schema specified in this appendix accomplishes its integration by importing the XML Schema defined for XQueryX in [XQueryX 3.0], incorporating all of its type and element definitions. It then extends that schema by adding definitions of new types and elements in a namespace belonging to the Update Facility specification, as well as redefining one complex type.
This section specifies the two XML Schemas that define the complex types and elements for XQueryX in support of XQuery Update Facility 3.0, including changes to the prolog and the addition of several new expressions.
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xqx="http://www.w3.org/2005/XQueryX" xmlns:xqxuf="http://www.w3.org/2007/xquery-update-10" targetNamespace="http://www.w3.org/2007/xquery-update-10" elementFormDefault="qualified" attributeFormDefault="unqualified"> <!-- Initial creation 2006-08-17: Jim Melton --> <!-- Added ufRevalidationDecl 2006-08-21: Jim Melton --> <!-- Overhaul to bring up to date 2007-08-07: Jim Melton --> <!-- Reconfirmed correctness for CR 2008-02-27: Jim Melton --> <!-- Added copyModifyExpr as alias for transformExpr 2014-11-06: Jim Melton --> <!-- Added transformWithExpr 2014-11-06: Jim Melton --> <!-- Added updatingFunctionCall 2014-11-06: Jim Melton --> <xsd:import namespace="http://www.w3.org/2005/XQueryX" schemaLocation="http://www.w3.org/2007/xquery-update-10/ xquery-update-10-xqueryx-redef.xsd"/> <!-- Add revalidationDecl to alternatives in prolog setters --> <xsd:element name="revalidationDecl" substitutionGroup="xqx:prologPartOneItem"> <xsd:simpleType> <xsd:restriction base="xsd:NMTOKEN"> <xsd:enumeration value="strict"/> <xsd:enumeration value="lax"/> <xsd:enumeration value="skip"/> </xsd:restriction> </xsd:simpleType> </xsd:element> <!-- Create substitution group for update facility exprs --> <xsd:complexType name="expr"> <xsd:complexContent> <xsd:extension base="xqx:expr"/> </xsd:complexContent> </xsd:complexType> <!-- Make the update facilities subst grp part of expr grp --> <xsd:element name="expr" type="xqxuf:expr" abstract="true" substitutionGroup="xqx:expr"/> <!-- InsertExpr --> <xsd:complexType name="insertExpr"> <xsd:complexContent> <xsd:extension base="xqxuf:expr"> <xsd:sequence> <xsd:element name="sourceExpr" type="xqx:exprWrapper"/> <xsd:choice> <xsd:element name="insertInto"> <xsd:complexType> <xsd:sequence minOccurs="0" maxOccurs="1"> <xsd:choice> <xsd:element name="insertAsFirst" type="xqx:emptyContent"/> <xsd:element name="insertAsLast" type="xqx:emptyContent"/> </xsd:choice> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="insertAfter" type="xqx:emptyContent"/> <xsd:element name="insertBefore" type="xqx:emptyContent"/> </xsd:choice> <xsd:element name="targetExpr" type="xqx:exprWrapper"/> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType> <xsd:element name="insertExpr" type="xqxuf:insertExpr" substitutionGroup="xqxuf:expr"/> <!-- DeleteExpr --> <xsd:complexType name="deleteExpr"> <xsd:complexContent> <xsd:extension base="xqxuf:expr"> <xsd:sequence> <xsd:element name="targetExpr" type="xqx:exprWrapper"/> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType> <xsd:element name="deleteExpr" type="xqxuf:deleteExpr" substitutionGroup="xqxuf:expr"/> <!-- ReplaceExpr --> <xsd:complexType name="replaceExpr"> <xsd:complexContent> <xsd:extension base="xqxuf:expr"> <xsd:sequence> <xsd:element name="replaceValue" type="xqx:emptyContent" minOccurs="0" maxOccurs="1"/> <xsd:element name="targetExpr" type="xqx:exprWrapper"/> <xsd:element name="replacementExpr" type="xqx:exprWrapper"/> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType> <xsd:element name="replaceExpr" type="xqxuf:replaceExpr" substitutionGroup="xqxuf:expr"/> <!-- RenameExpr --> <xsd:complexType name="renameExpr"> <xsd:complexContent> <xsd:extension base="xqxuf:expr"> <xsd:sequence> <xsd:element name="targetExpr" type="xqx:exprWrapper"/> <xsd:element name="newNameExpr" type="xqx:exprWrapper"/> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType> <xsd:element name="renameExpr" type="xqxuf:renameExpr" substitutionGroup="xqxuf:expr"/> <!-- TransformExpr --> <xsd:complexType name="transformExpr"> <xsd:complexContent> <xsd:extension base="xqxuf:expr"> <xsd:sequence> <xsd:element name="transformCopies"> <xsd:complexType> <xsd:sequence> <xsd:element name="transformCopy" minOccurs="1" maxOccurs="unbounded"> <xsd:complexType> <xsd:sequence> <xsd:element ref="xqx:varRef"/> <xsd:element name="copySource" type="xqx:exprWrapper"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="modifyExpr" type="xqx:exprWrapper"/> <xsd:element name="returnExpr" type="xqx:exprWrapper"/> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType> <xsd:element name="transformExpr" type="xqxuf:transformExpr" substitutionGroup="xqxuf:expr"/> <xsd:element name="copyModifyExpr" type="xqxuf:transformExpr" substitutionGroup="xqxuf:expr"/> <!-- TransformWithExpr --> <xsd:complexType name="transformWithExpr"> <xsd:complexContent> <xsd:extension base="xqxuf:expr"> <xsd:sequence> <xsd:element ref="pathExpr"/> <xsd:element ref="xqxuf:expr" minOccurs="0"/> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType> <xsd:element name="transformWithExpr" type="xqxuf:transformWithExpr" substitutionGroup="xqxuf:expr"/> <!-- UpdatingFunctionCall --> <xsd:element name="updatingFunctionCall" type="xqx:functionCallExpr" substitutionGroup="xqxuf:expr"/> </xsd:schema> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/2005/XQueryX" targetNamespace="http://www.w3.org/2005/XQueryX" elementFormDefault="qualified" attributeFormDefault="qualified"> <!-- Redefine one or more components of the XQueryX XML Schema --> <xsd:redefine schemaLocation="http://www.w3.org/2005/XQueryX/xqueryx.xsd"> <!-- Redefine the functionDecl complex type --> <xsd:complexType name="functionDecl"> <xsd:complexContent> <xsd:extension base="functionDecl"> <xsd:attribute name="updatingFunction" type="xsd:boolean" default="false"/> </xsd:extension> </xsd:complexContent> </xsd:complexType> <!-- Redefine the simpleMapExpr complex type --> <xsd:complexType name="simpleMapExpr"> <xsd:complexContent> <xsd:extension base="expr"> <xsd:sequence minOccurs="2" maxOccurs="unbounded"> <xsd:choice> <xsd:element ref="pathExpr"/> <xsd:element ref="transformWithExpr"/> </xsd:choice> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType> </xsd:redefine> </xsd:schema>
This section specifies the XSLT stylesheet that defines the semantics of XQueryX in support of XQuery Update Facility 3.0. It imports the XSLT stylesheet defined in [XQueryX 3.0], and provides additional templates that define the semantics of the XQueryX representation of XQuery Update Facility 3.0 by transforming that XQueryX representation into the human readable syntax of XQuery Update Facility 3.0.
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xqxuf="http://www.w3.org/2007/xquery-update-10" xmlns:xqx="http://www.w3.org/2005/XQueryX"> <!-- Initial creation 2006-08-17: Jim Melton --> <!-- Added revalidationDecl 2006-08-21: Jim Melton --> <!-- Bring up to date with spec 2007-08-07: Jim Melton --> <!-- Surround updating exprs w/parens 2007-09-13: Jim Melton --> <!-- Added copyModifyExpr as alias for transformExpr 2014-11-06: Jim Melton --> <!-- Added transformWithExpr 2014-11-06: Jim Melton --> <!-- Added updatingFunctionCall 2014-11-06: Jim Melton --> <xsl:import href="http://www.w3.org/2005/XQueryX/xqueryx.xsl"/> <!-- revalidationDecl --> <xsl:template match="xqxuf:revalidationDecl"> <xsl:text>declare revalidation </xsl:text> <xsl:apply-templates/> </xsl:template> <!-- insertExpr --> <xsl:template match="xqxuf:insertExpr"> <xsl:value-of select="$LPAREN"/> <xsl:text>insert nodes </xsl:text> <xsl:value-of select="$NEWLINE"/> <xsl:apply-templates select="xqxuf:sourceExpr"/> <xsl:value-of select="$NEWLINE"/> <xsl:apply-templates select="xqxuf:insertInto | xqxuf:insertBefore | xqxuf:insertAfter"/> <xsl:value-of select="$NEWLINE"/> <xsl:apply-templates select="xqxuf:targetExpr"/> <xsl:value-of select="$RPAREN"/> </xsl:template> <!-- sourceExpr --> <xsl:template match="xqxuf:sourceExpr"> <xsl:apply-templates/> </xsl:template> <!-- insertInto --> <xsl:template match="xqxuf:insertInto"> <xsl:if test="child::node()"> <xsl:text>as </xsl:text> </xsl:if> <xsl:apply-templates/> <xsl:text>into </xsl:text> </xsl:template> <!-- insertAsFirst --> <xsl:template match="xqxuf:insertAsFirst"> <xsl:text>first </xsl:text> </xsl:template> <!-- insertAsLast --> <xsl:template match="xqxuf:insertAsLast"> <xsl:text>last </xsl:text> </xsl:template> <!-- insertAfter --> <xsl:template match="xqxuf:insertAfter"> <xsl:text>after </xsl:text> </xsl:template> <!-- insertBefore --> <xsl:template match="xqxuf:insertBefore"> <xsl:text>before </xsl:text> </xsl:template> <!-- targetExpr --> <xsl:template match="xqxuf:targetExpr"> <xsl:apply-templates/> </xsl:template> <!-- deleteExpr --> <xsl:template match="xqxuf:deleteExpr"> <xsl:value-of select="$LPAREN"/> <xsl:text>delete nodes </xsl:text> <xsl:apply-templates/> <xsl:value-of select="$RPAREN"/> </xsl:template> <!-- replaceExpr --> <xsl:template match="xqxuf:replaceExpr"> <xsl:value-of select="$LPAREN"/> <xsl:text>replace </xsl:text> <xsl:if test="xqxuf:replaceValue"> <xsl:text>value of </xsl:text> </xsl:if> <xsl:text>node </xsl:text> <xsl:apply-templates select="xqxuf:targetExpr"/> <xsl:text> with </xsl:text> <xsl:apply-templates select="xqxuf:replacementExpr"/> <xsl:value-of select="$RPAREN"/> </xsl:template> <!-- replacementExpr --> <xsl:template match="xqxuf:replacementExpr"> <xsl:apply-templates/> </xsl:template> <!-- renameExpr --> <xsl:template match="xqxuf:renameExpr"> <xsl:value-of select="$LPAREN"/> <xsl:text>rename node </xsl:text> <xsl:apply-templates select="xqxuf:targetExpr"/> <xsl:text> as </xsl:text> <xsl:apply-templates select="xqxuf:newNameExpr"/> <xsl:value-of select="$RPAREN"/> </xsl:template> <!-- newNameExpr --> <xsl:template match="xqxuf:newNameExpr"> <xsl:apply-templates/> </xsl:template> <!-- transformExpr/copyModifyExpr --> <xsl:template match="xqxuf:transformExpr | xqxuf:copyModifyExpr"> <xsl:value-of select="$LPAREN"/> <xsl:text>copy </xsl:text> <xsl:apply-templates select="xqxuf:transformCopies"/> <xsl:value-of select="$NEWLINE"/> <xsl:text> modify </xsl:text> <xsl:apply-templates select="xqxuf:modifyExpr"/> <xsl:value-of select="$NEWLINE"/> <xsl:text> return </xsl:text> <xsl:apply-templates select="xqxuf:returnExpr"/> <xsl:value-of select="$RPAREN"/> </xsl:template> <!-- Part of transformExpr --> <xsl:template match="xqxuf:transformCopies"> <xsl:call-template name="commaSeparatedList"/> </xsl:template> <!-- Part of transformExpr --> <xsl:template match="xqxuf:transformCopy"> <xsl:apply-templates select="xqx:varRef"/> <xsl:text> := </xsl:text> <xsl:apply-templates select="xqxuf:copySource"/> </xsl:template> <!-- Part of transformExpr --> <xsl:template match="xqxuf:copySource"> <xsl:apply-templates/> </xsl:template> <!-- Part of transformExpr --> <xsl:template match="xqxuf:modifyExpr"> <xsl:apply-templates/> </xsl:template> <!-- Part of transformExpr --> <xsl:template match="xqxuf:returnExpr"> <xsl:apply-templates/> </xsl:template> <!-- Over-ride the template for functionDecl in XQueryX.xsd --> <!-- [33] FunctionDecl ::= "function" EQName "(" ParamList? ")" ("as" SequenceType)? (FunctionBody | "external") --> <xsl:template match="xqx:functionDecl" priority="100"> <xsl:text>declare</xsl:text> <xsl:apply-templates select="xqx:annotation"/> <xsl:if test="@xqx:updatingFunction and @xqx:updatingFunction = 'true'"> <xsl:text>updating </xsl:text> </xsl:if> <xsl:text> function </xsl:text> <xsl:apply-templates select="xqx:functionName"/> <xsl:apply-templates select="xqx:paramList"/> <xsl:apply-templates select="xqx:typeDeclaration"/> <xsl:choose> <xsl:when test="xqx:externalDefinition"> <xsl:text> external </xsl:text> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="xqx:functionBody"/> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="xqx:functionDecl" priority="100"> <xsl:text>declare </xsl:text> <xsl:if test="@xqx:updatingFunction and @xqx:updatingFunction = 'true'"> <xsl:text>updating </xsl:text> </xsl:if> <xsl:text>function </xsl:text> <xsl:apply-templates select="xqx:functionName"/> <xsl:apply-templates select="xqx:paramList"/> <xsl:apply-templates select="xqx:typeDeclaration"/> <xsl:apply-templates select="xqx:functionBody"/> <xsl:if test="xqx:externalDefinition"> <xsl:text> external </xsl:text> </xsl:if> </xsl:template> <!-- transformWithExpr --> <xsl:template match="xqx:transformWithExpr"> <xsl:text>transform with</xsl:text> <xsl:value-of select="$SPACE"/> <xsl:value-of select="$LBRACE"/> <xsl:value-of select="$SPACE"/> <xsl:apply-templates select="."/> <xsl:value-of select="$SPACE"/> <xsl:value-of select="$RBRACE"/> <xsl:value-of select="$NEWLINE"/> </xsl:template> <!-- updatingFunctionCall --> <xsl:template match="xqx:updatingFunctionCall"> <xsl:if test="(xqx:functionName = 'node' or xqx:functionName = 'document-node' or xqx:functionName = 'element' or xqx:functionName = 'attribute' or xqx:functionName = 'schema-element' or xqx:functionName = 'schema-attribute' or xqx:functionName = 'processing-instruction' or xqx:functionName = 'comment' or xqx:functionName = 'text' or xqx:functionName = 'function' or xqx:functionName = 'namespace-node' or xqx:functionName = 'item' or xqx:functionName = 'if' or xqx:functionName = 'switch' or xqx:functionName = 'typeswitch' or xqx:functionName = 'empty-sequence') and ((not(xqx:functionName/@xqx:prefix) and not(xqx:functionName/@xqx:URI)) or xqx:functionName/@xqx:prefix = '' or xqx:functionName/@xqx:URI = '')"> <xsl:variable name="message"> <xsl:text>Incorrect XQueryX: function calls must not use unqualified "reserved" name "</xsl:text> <xsl:value-of select="xqx:functionName"/> <xsl:text>"</xsl:text> </xsl:variable> <xsl:message terminate="yes"><xsl:value-of select="$message"/></xsl:message> </xsl:if> <xsl:text>invoke updating </xsl:text> <xsl:apply-templates select="xqx:functionName"/> <xsl:choose> <xsl:when test="xqx:arguments"> <xsl:for-each select="xqx:arguments"> <xsl:call-template name="parenthesizedList"/> </xsl:for-each> </xsl:when> <xsl:otherwise> <xsl:value-of select="$LPAREN"/> <xsl:value-of select="$RPAREN"/> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet>
The following example is based on the data and queries in the use cases in [XQuery Update Facility 3.0 Requirements and Use Cases]. In this example, we show the English description of the query, the XQuery Update Facility solution given in [XQuery Update Facility 3.0 Requirements and Use Cases], an XQueryX solution, and the XQuery Update Facility expression that results from applying the Update Facility XQueryX-to-XQuery Update Facility transformation defined by the stylesheet in [E.2 Stylesheet] to the Update Facility XQueryX solution. The XQuery Update Facility expression that is produced is presented only as a sanity-check—the intent of the stylesheet is not to recreate the original XQuery expression, but to produce a valid XQuery expression with the same semantics. The semantics of the Update Facility XQueryX solution are determined by the semantics of the XQuery Update Facility expression that results from that transformation. The "correctness" of that transformation is determined by asking the following the question: Can some Update Facility XQueryX processor QX process some Update Facility XQueryX document D1 to produce results R1, after which the stylesheet is used to translate D1 into an XQuery Update Facility expression E1 that, when processed by some XQuery Update Facility processor Q, produces results R2 that are equivalent (under some meaningful definition of "equivalent") to results R1?
Comparison of the results of the Update Facility XQueryX-to-XQuery Update Facility transformation given in this document with the XQuery Update Facility solutions in [XQuery Update Facility 3.0 Requirements and Use Cases] may be helpful in evaluating the correctness of the Update Facility XQueryX solution in each example.
The XQuery Update Facility Use Cases solution given for each example is provided only to assist readers of this document in understanding the Update Facility XQueryX solution. There is no intent to imply that this document specifies a "compilation" or "transformation" of XQuery Update Facility syntax into Update Facility XQueryX syntax.
In the following example, note that path expressions are expanded to show their structure. Also, note that the prefix syntax for binary operators like "and" makes the precedence explicit. In general, humans find it easier to read an XML representation that does not expand path expressions, but it is less convenient for programmatic representation and manipulation. XQueryX is designed as a language that is convenient for production and modification by software, and not as a convenient syntax for humans to read and write.
Finally, please note that white space, including new lines, have been added to some of the Update Facility XQueryX documents and XQuery Update Facility expressions for readability. That additional white space is not produced by the Update Facility XQueryX-to-XQuery Update Facility transformation.
This example is based on Q6 from [XQuery Update Facility 3.0 Requirements and Use Cases], use case Parts: "modifying recursive documents":
for $keyword at $i in ("car", "skateboard", "canoe"), $parent in doc("part-tree.xml")//part[@name=$keyword] let $descendants := $parent//part for $p in ($parent, $descendants) return replace value of node $p/@partid with $i*1000+$p/@partid
<?xml version="1.0"?> <xqx:module xmlns:xqxuf="http://www.w3.org/2007/xquery-update-10" xmlns:xqx="http://www.w3.org/2005/XQueryX" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2007/xquery-update-10 http://www.w3.org/2007/xquery-update-10/xquery-update-10-xqueryx.xsd http://www.w3.org/2005/XQueryX http://www.w3.org/2005/XQueryX/xqueryx.xsd"> <xqx:versionDecl> <xqx:version>1.0</xqx:version> </xqx:versionDecl> <xqx:mainModule> <xqx:queryBody> <xqx:flworExpr> <xqx:forClause> <xqx:forClauseItem> <xqx:typedVariableBinding> <xqx:varName>keyword</xqx:varName> </xqx:typedVariableBinding> <xqx:positionalVariableBinding>i </xqx:positionalVariableBinding> <xqx:forExpr> <xqx:sequenceExpr> <xqx:stringConstantExpr> <xqx:value>car</xqx:value> </xqx:stringConstantExpr> <xqx:stringConstantExpr> <xqx:value>skateboard</xqx:value> </xqx:stringConstantExpr> <xqx:stringConstantExpr> <xqx:value>canoe</xqx:value> </xqx:stringConstantExpr> </xqx:sequenceExpr> </xqx:forExpr> </xqx:forClauseItem> <xqx:forClauseItem> <xqx:typedVariableBinding> <xqx:varName>parent</xqx:varName> </xqx:typedVariableBinding> <xqx:forExpr> <xqx:pathExpr> <xqx:stepExpr> <xqx:filterExpr> <xqx:functionCallExpr> <xqx:functionName xqx:prefix="fn">doc</xqx:functionName> <xqx:arguments> <xqx:stringConstantExpr> <xqx:value>part-tree.xml</xqx:value> </xqx:stringConstantExpr> </xqx:arguments> </xqx:functionCallExpr> </xqx:filterExpr> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>descendant-or-self</xqx:xpathAxis> <xqx:nameTest>part</xqx:nameTest> <xqx:predicates> <xqx:equalOp> <xqx:firstOperand> <xqx:pathExpr> <xqx:stepExpr> <xqx:xpathAxis>attribute</xqx:xpathAxis> <xqx:nameTest>name</xqx:nameTest> </xqx:stepExpr> </xqx:pathExpr> </xqx:firstOperand> <xqx:secondOperand> <xqx:varRef> <xqx:name>keyword</xqx:name> </xqx:varRef> </xqx:secondOperand> </xqx:equalOp> </xqx:predicates> </xqx:stepExpr> </xqx:pathExpr> </xqx:forExpr> </xqx:forClauseItem> </xqx:forClause> <xqx:letClause> <xqx:letClauseItem> <xqx:typedVariableBinding> <xqx:varName>descendants</xqx:varName> </xqx:typedVariableBinding> <xqx:letExpr> <xqx:pathExpr> <xqx:stepExpr> <xqx:filterExpr> <xqx:varRef> <xqx:name>parent</xqx:name> </xqx:varRef> </xqx:filterExpr> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>descendant-or-self</xqx:xpathAxis> <xqx:nameTest>part</xqx:nameTest> </xqx:stepExpr> </xqx:pathExpr> </xqx:letExpr> </xqx:letClauseItem> </xqx:letClause> <xqx:forClause> <xqx:forClauseItem> <xqx:typedVariableBinding> <xqx:varName>p</xqx:varName> </xqx:typedVariableBinding> <xqx:forExpr> <xqx:sequenceExpr> <xqx:varRef> <xqx:name>parent</xqx:name> </xqx:varRef> <xqx:varRef> <xqx:name>descendants</xqx:name> </xqx:varRef> </xqx:sequenceExpr> </xqx:forExpr> </xqx:forClauseItem> </xqx:forClause> <xqx:returnClause> <xqxuf:replaceExpr> <xqxuf:replaceValue/> <xqxuf:targetExpr> <xqx:pathExpr> <xqx:stepExpr> <xqx:filterExpr> <xqx:varRef> <xqx:name>p</xqx:name> </xqx:varRef> </xqx:filterExpr> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>attribute</xqx:xpathAxis> <xqx:nameTest>partid</xqx:nameTest> </xqx:stepExpr> </xqx:pathExpr> </xqxuf:targetExpr> <xqxuf:replacementExpr> <xqx:addOp> <xqx:firstOperand> <xqx:multiplyOp> <xqx:firstOperand> <xqx:varRef> <xqx:name>i</xqx:name> </xqx:varRef> </xqx:firstOperand> <xqx:secondOperand> <xqx:integerConstantExpr> <xqx:value>1000</xqx:value> </xqx:integerConstantExpr> </xqx:secondOperand> </xqx:multiplyOp> </xqx:firstOperand> <xqx:secondOperand> <xqx:pathExpr> <xqx:stepExpr> <xqx:filterExpr> <xqx:varRef> <xqx:name>p</xqx:name> </xqx:varRef> </xqx:filterExpr> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>attribute</xqx:xpathAxis> <xqx:nameTest>partid</xqx:nameTest> </xqx:stepExpr> </xqx:pathExpr> </xqx:secondOperand> </xqx:addOp> </xqxuf:replacementExpr> </xqxuf:replaceExpr> </xqx:returnClause> </xqx:flworExpr> </xqx:queryBody> </xqx:mainModule> </xqx:module>
Application of the stylesheet in [E.2 Stylesheet] to the Update Facility XQueryX representation results in the following XQuery representation:
xquery version "1.0"; ( for $keyword at $i in ("car", "skateboard", "canoe"), $parent in fn:doc("part-tree.xml")/descendant-or-self::part [(attribute::name = $keyword)] let $descendants:=$parent/descendant-or-self::part for $p in ($parent, $descendants) return replace value of node $p/attribute::partid with (($i*1000)+$p/attribute::partid) )