XQueryX 3.0 /**/ /* from xsl:query.xsl (C) */ code { font-family: monospace; }
div.constraint, div.issue, div.note, div.notice { margin-left: 2em; }
div.issue p.title { margin-left: -2em; }
ol.enumar { list-style-type: decimal; } ol.enumla { list-style-type: lower-alpha; } ol.enumlr { list-style-type: lower-roman; } ol.enumua { list-style-type: upper-alpha; } ol.enumur { list-style-type: upper-roman; }
li p { margin-top: 0.3em; margin-bottom: 0.3em; }
sup small { font-style: italic; color: #8F8F8F; } /* from xsl:query.xsl (D) */ div.exampleInner pre { margin-left: 1em; margin-top: 0em; margin-bottom: 0em} div.exampleOuter {border: 4px double gray; margin: 0em; padding: 0em} div.exampleInner { background-color: #d5dee3; border-top-width: 4px; border-top-style: double; border-top-color: #d3d3d3; border-bottom-width: 4px; border-bottom-style: double; border-bottom-color: #d3d3d3; padding: 4px; margin: 0em } div.exampleWrapper { margin: 4px } div.exampleHeader { font-weight: bold; margin: 4px}
div.issue { border-bottom-color: black; border-bottom-style: solid; border-bottom-width: 1pt; margin-bottom: 20pt; }
th.issue-toc-head { border-bottom-color: black; border-bottom-style: solid; border-bottom-width: 1pt; }
/* from xsl-query.xsl (B) */ table.small { font-size: x-small; } a.judgment:visited, a.judgment:link { font-family: sans-serif; color: black; text-decoration: none } a.processing:visited, a.processing:link { color: black; text-decoration: none } a.env:visited, a.env:link { color: black; text-decoration: none } /** Advisement Box ************************************************************/ /* for attention-grabbing normative statements */
.advisement { border-color: orange; border-style: none solid; background: #fec; color: black; padding: .5em; border-width: .5em; page-break-inside: avoid; margin: 1em auto; }
/**/ Status Update (6 April 2021): Feedback, comments, error reports on this specification should be sent via GitHub https://github.com/w3c/qtspecs/issues [email protected] This version: http://www.w3.org/TR/2014/REC-xqueryx-30-20140408/ Latest version of XQueryX 3.0: http://www.w3.org/TR/xqueryx-30/ Previous versions of XQueryX 3.0: http://www.w3.org/TR/2014/PR-xqueryx-30-20140130/ http://www.w3.org/TR/2013/WD-xqueryx-30-20131001/ http://www.w3.org/TR/2013/CR-xqueryx-30-20130108/ http://www.w3.org/TR/2011/WD-xqueryx-30-20111213/ http://www.w3.org/TR/2011/WD-xqueryx-30-20110614/ http://www.w3.org/TR/2010/WD-xqueryx-30-20101214/ http://www.w3.org/TR/2009/WD-xqueryx-11-20091215/ http://www.w3.org/TR/2008/WD-xqueryx-11-20081203/ Most recent version of XQueryX 3: http://www.w3.org/TR/xqueryx-3/ Most recent Recommendation of XQueryX: http://www.w3.org/TR/2010/REC-xqueryx-20101214/ Editor: Jim Melton, Oracle <[email protected]> Please check the errata See also translations This document is also available in these non-normative formats: XML Change markings relative to previous edition Most recent XQueryX Recommendation Copyright W3C ® MIT ERCIM Keio Beihang liability trademark document use This document defines an XML Syntax for [XQuery 3.0: An XML Query Language] This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index This is one document in a set of six documents that have been progressed to Recommendation together (XQuery 3.0, XQueryX 3.0, XPath 3.0, Data Model 3.0, Functions and Operators 3.0, and Serialization 3.0). This is a Recommendation XML Query Working Group XML Activity This Recommendation of XQueryX 3.0 represents the second version of a previous W3C Recommendation A Test Suite has been created for this document. Implementors are encouraged to run this test suite and report their results. The Test Suite can be found at http://dev.w3.org/2011/QT3-test-suite/ implementation report This document incorporates minor changes made against the Proposed Recommendation Proposed Recommendation D Change log Please report errors in this document using W3C's public Bugzilla system http://www.w3.org/XML/2005/04/qt-bugzilla [email protected] http://lists.w3.org/Archives/Public/public-qt-comments/ This document has been reviewed by W3C Members, by software developers, and by other W3C groups and interested parties, and is endorsed by the Director as a W3C Recommendation. It is a stable document and may be used as reference material or cited from another document. W3C's role in making the Recommendation is to draw attention to the specification and to promote its widespread deployment. This enhances the functionality and interoperability of the Web. This document was produced by a group operating under the 5 February 2004 W3C Patent Policy public list of any patent disclosures Essential Claim(s) section 6 of the W3C Patent Policy 1 Introduction Mapping the XQuery Syntax Examples from the XML Query Use Cases in XML Syntax Example 1 XQuery solution in XQuery Use Cases: A Solution in XQueryX: Transformation of XQueryX Solution into XQuery Corresponding Grammar Abstract Parse Tree Example 2 XQuery solution in XQuery Use Cases: A solution in XQueryX: Transformation of XQueryX Solution into XQuery Example 3 XQuery solution in XQuery Use Cases: A solution in XQueryX: Transformation of XQueryX Solution into XQuery Example 4 XQuery solution in XQuery Use Cases: A solution in XQueryX: Transformation of XQueryX Solution into XQuery An XML Schema for the XQuery XML Syntax Conformance A References Transforming XQueryX to XQuery The application/xquery+xml Media Type Introduction Registration of MIME Media Type application/xquery+xml Encoding Considerations Security Considerations Interoperability Considerations Published specification Applications That Use This Media Type Additional Information Recognizing XQuery Files ("Magic Numbers") File Extensions Macintosh File Type Code(s) Person and Email Address to Contact For Further Information Intended Usage Restrictions on usage Author/Change Controller Fragment Identifiers Change log Substantive changes Incompatibilities Editorial changes The [XQuery 3.0 Requirements] XQueryX is an XML representation of an XQuery. It was created by mapping the productions of the XQuery grammar into XML productions. The result is not particularly convenient for humans to read and write, but it is easy for programs to parse, and because XQueryX is represented in XML, standard XML tools can be used to create, interpret, or modify queries. In this document, examples and material labeled as "Note" are provided for explanatory purposes and are not normative. Note: Because the two syntaxes are merely different grammars that express the same query semantics, they share all aspects of an XQuery processing system except for the component that recognizes and translates the source representation of a query (that is, the parser). The aspects that are shared include both the static context and the dynamic context that are defined in [XQuery 3.0: An XML Query Language] There are several environments in which XQueryX may be useful: Parser Reuse. Queries on Queries. Generating Queries. Embedding Queries in XML. This version of XQueryX is fully compatible with [XML Syntax for XQuery 1.0 (XQueryX)] [XML Syntax for XQuery 1.0 (XQueryX)] The most recent versions of the XQueryX XML Schema and the XQueryX XSLT stylesheet are available at http://www.w3.org/2014/04/XQueryX/xqueryx.xsd http://www.w3.org/2014/04/XQueryX/xqueryx.xsl Note: The locations at which the current versions of the XML Schema and XSLT stylesheet are located during development of this specification will vary with each Working Draft and Candidate Recommendation of the spec that is published. The namespace target URI is identical to that used for [XML Syntax for XQuery 1.0 (XQueryX)] XQueryX is an XML representation of the abstract syntax found in Appendix A of [XQuery 3.0: An XML Query Language] 4 An XML Schema for the XQuery XML Syntax B Transforming XQueryX to XQuery The main data structure in the XQueryX Schema is the set of types that describe expressions. We have chosen to model expressions using substitution groups, with an "expr" abstract base class and a number of intermediate abstract classes. Consider the following productions from the abstract syntax: FLWORExpr ::= InitialClause IntermediateClause* ReturnClause InitialClause ::= ForClause | LetClause | WindowClause IntermediateClause ::= InitialClause | WhereClause | GroupByClause | OrderByClause | CountClause ForClause ::= "for" "$" VarName TypeDeclaration? ("allowing" "empty")? PositionalVar? "in" ExprSingle Note: Those productions do not represent the entire FLWOR expression, so some of the BNF non-terminal names are not resolved in the example abstract syntax. The following XQueryX Schema definitions reflect the structure of those productions from that abstract syntax: <!-- The base class --> <xsd:complexType name="expr"/> <xsd:element name="expr" type="expr" abstract="true"/>
<!-- Simple wrapper class --> <xsd:complexType name="exprWrapper"> <xsd:sequence> <xsd:element ref="expr"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="flworExpr"> <xsd:complexContent> <xsd:extension base="expr"> <xsd:sequence> <xsd:choice> <xsd:element ref="forClause"/> <xsd:element ref="letClause"/> <xsd:element ref="windowClause"/> </xsd:choice> <xsd:sequence> <xsd:choice minOccurs="0" maxOccurs="unbounded"> <xsd:element ref="forClause"/> <xsd:element ref="letClause"/> <xsd:element ref="windowClause"/> <xsd:element ref="countClause"/> <xsd:element ref="whereClause"/> <xsd:element ref="groupByClause"/> <xsd:element ref="orderByClause"/> </xsd:choice> <xsd:element ref="returnClause"/> </xsd:sequence> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType>
<xsd:element name="flworExpr" type="flworExpr" substitutionGroup="expr"/>
<xsd:complexType name="forClause"> <xsd:sequence> <xsd:element ref="forClauseItem" minOccurs="1" maxOccurs="unbounded"/> </xsd:sequence>
</xsd:complexType>
<xsd:element name="forClause" type="forClause"/>
<xsd:complexType name="forClauseItem"> <xsd:sequence> <xsd:element ref="typedVariableBinding"/> <xsd:element name="allowingEmpty" type="emptyContent" minOccurs="0"/> Since XQuery uses the expression production liberally to allow expressions to be flexibly combined, XQueryX uses the exprWrapper type in embedded contexts to allow all expression types to occur. Three of following examples are based on the data and queries in the XMP (Experiences and Exemplars) use case in [XQuery 3.0 Use Cases] [XQuery 3.0 Use Cases] B Transforming XQueryX to XQuery [XQuery 3.0 Use Cases] a Comparison of the results of the XQueryX-to-XQuery transformation given in this document with the XQuery solutions in the [XQuery 3.0 Use Cases] The XQuery Use Cases solution given for each example is provided only to assist readers of this document in understanding the XQueryX solution. There is no intent to imply that this document specifies a "compilation" or "transformation" of XQuery syntax into XQueryX syntax. In the following examples, 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 XQueryX documents and XQuery expressions for readability. That additional white space is not produced by the XQueryX-to-XQuery transformation. Here is Q1 from the [XQuery 3.0 Use Cases] <bib> { for $b in doc("http://bstore1.example.com/bib.xml")/bib/book where $b/publisher = "Addison-Wesley" and $b/@year > 1991 return <book year="{ $b/@year }"> { $b/title } </book> } </bib> <?xml version="1.0"?> <xqx:module xmlns:xqx="http://www.w3.org/2005/XQueryX" 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"> <xqx:mainModule> <xqx:queryBody> <xqx:elementConstructor> <xqx:tagName>bib</xqx:tagName> <xqx:elementContent> <xqx:flworExpr> <xqx:forClause> <xqx:forClauseItem> <xqx:typedVariableBinding> <xqx:varName>b</xqx:varName> </xqx:typedVariableBinding> <xqx:forExpr> <xqx:pathExpr> <xqx:stepExpr> <xqx:filterExpr> <xqx:functionCallExpr> <xqx:functionName>doc</xqx:functionName> <xqx:arguments> <xqx:stringConstantExpr> <xqx:value>http://bstore1.example.com/bib.xml</xqx:value> </xqx:stringConstantExpr> </xqx:arguments> </xqx:functionCallExpr> </xqx:filterExpr> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>child</xqx:xpathAxis> <xqx:nameTest>bib</xqx:nameTest> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>child</xqx:xpathAxis> <xqx:nameTest>book</xqx:nameTest> </xqx:stepExpr> </xqx:pathExpr> </xqx:forExpr> </xqx:forClauseItem> </xqx:forClause> <xqx:whereClause> <xqx:andOp> <xqx:firstOperand> <xqx:equalOp> <xqx:firstOperand> <xqx:pathExpr> <xqx:stepExpr> <xqx:filterExpr> <xqx:varRef> <xqx:name>b</xqx:name> </xqx:varRef> </xqx:filterExpr> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>child</xqx:xpathAxis> <xqx:nameTest>publisher</xqx:nameTest> </xqx:stepExpr> </xqx:pathExpr> </xqx:firstOperand> <xqx:secondOperand> <xqx:stringConstantExpr> <xqx:value>Addison-Wesley</xqx:value> </xqx:stringConstantExpr> </xqx:secondOperand> </xqx:equalOp> </xqx:firstOperand> <xqx:secondOperand> <xqx:greaterThanOp> <xqx:firstOperand> <xqx:pathExpr> <xqx:stepExpr> <xqx:filterExpr> <xqx:varRef> <xqx:name>b</xqx:name> </xqx:varRef> </xqx:filterExpr> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>attribute</xqx:xpathAxis> <xqx:nameTest>year</xqx:nameTest> </xqx:stepExpr> </xqx:pathExpr> </xqx:firstOperand> <xqx:secondOperand> <xqx:integerConstantExpr> <xqx:value>1991</xqx:value> </xqx:integerConstantExpr> </xqx:secondOperand> </xqx:greaterThanOp> </xqx:secondOperand> </xqx:andOp> </xqx:whereClause> <xqx:returnClause> <xqx:elementConstructor> <xqx:tagName>book</xqx:tagName> <xqx:attributeList> <xqx:attributeConstructor> <xqx:attributeName>year</xqx:attributeName> <xqx:attributeValueExpr> <xqx:pathExpr> <xqx:stepExpr> <xqx:filterExpr> <xqx:varRef> <xqx:name>b</xqx:name> </xqx:varRef> </xqx:filterExpr> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>attribute</xqx:xpathAxis> <xqx:nameTest>year</xqx:nameTest> </xqx:stepExpr> </xqx:pathExpr> </xqx:attributeValueExpr> </xqx:attributeConstructor> </xqx:attributeList> <xqx:elementContent> <xqx:pathExpr> <xqx:stepExpr> <xqx:filterExpr> <xqx:varRef> <xqx:name>b</xqx:name> </xqx:varRef> </xqx:filterExpr> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>child</xqx:xpathAxis> <xqx:nameTest>title</xqx:nameTest> </xqx:stepExpr> </xqx:pathExpr> </xqx:elementContent> </xqx:elementConstructor> </xqx:returnClause> </xqx:flworExpr> </xqx:elementContent> </xqx:elementConstructor> </xqx:queryBody> </xqx:mainModule> </xqx:module> Application of the stylesheet in B Transforming XQueryX to XQuery <bib>{ for $b in doc("http://bstore1.example.com/bib.xml")/child::bib/child::book where (($b/child::publisher = "Addison-Wesley") and ($b/attribute::year > 1991)) return <book year="{$b/attribute::year}">{$b/child::title}</book> }</bib> For comparison, here is the abstract parse tree corresponding to the XQuery for Example 1, as produced by the XQuery grammar applets found at http://www.w3.org/2007/01/applets/ XPath2 QueryList Module MainModule Prolog QueryBody Expr PathExpr Constructor DirectConstructor DirElemConstructor > LessThanOpOrTagO < TagQName bib DirAttributeList StartTagClose > DirElemContent ElementContentChar DirElemContent ElementContentChar DirElemContent CommonContent EnclosedExpr Lbrace { Expr FLWORExpr ForClause VarName QName b PathExpr FunctionCall FunctionQName doc PathExpr StringLiteral "http://bstore1.example.com/bib.xml" StepExpr AbbrevForwardStep NodeTest NameTest QName bib StepExpr AbbrevForwardStep NodeTest NameTest QName book WhereClause AndExpr and ComparisonExpr = PathExpr VarName QName b StepExpr AbbrevForwardStep NodeTest NameTest QName publisher PathExpr StringLiteral "Addison-Wesley" ComparisonExpr > PathExpr VarName QName b StepExpr AbbrevForwardStep @ NodeTest NameTest QName year PathExpr IntegerLiteral 1991 PathExpr Constructor DirectConstructor DirElemConstructor > LessThanOpOrTagO < TagQName book DirAttributeList S TagQName year ValueIndicator = DirAttributeValue OpenQuot " QuotAttrValueContent CommonContent EnclosedExpr Lbrace { Expr PathExpr VarName QName b StepExpr AbbrevForwardStep @ NodeTest NameTest QName year Rbrace } CloseQuot " StartTagClose > DirElemContent ElementContentChar DirElemContent ElementContentChar DirElemContent ElementContentChar DirElemContent ElementContentChar DirElemContent ElementContentChar DirElemContent ElementContentChar DirElemContent CommonContent EnclosedExpr Lbrace { Expr PathExpr VarName QName b StepExpr AbbrevForwardStep NodeTest NameTest QName title Rbrace } DirElemContent ElementContentChar DirElemContent ElementContentChar DirElemContent ElementContentChar DirElemContent ElementContentChar DirElemContent ElementContentChar Rbrace } DirElemContent ElementContentChar Here is Q4 from the [XQuery 3.0 Use Cases] <results> { let $a := doc("http://bstore1.example.com/bib/bib.xml")//author for $last in distinct-values($a/last), $first in distinct-values($a[last=$last]/first) order by $last, $first return <result> <author> <last>{ $last }</last> <first>{ $first }</first> </author> { for $b in doc("http://bstore1.example.com/bib.xml")/bib/book where some $ba in $b/author satisfies ($ba/last = $last and $ba/first=$first) return $b/title } </result> } </results> <?xml version="1.0"?> <xqx:module xmlns:xqx="http://www.w3.org/2005/XQueryX" 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"> <xqx:mainModule> <xqx:queryBody> <xqx:elementConstructor> <xqx:tagName>results</xqx:tagName> <xqx:elementContent> <xqx:flworExpr> <xqx:letClause> <xqx:letClauseItem> <xqx:typedVariableBinding> <xqx:varName>a</xqx:varName> </xqx:typedVariableBinding> <xqx:letExpr> <xqx:pathExpr> <xqx:stepExpr> <xqx:filterExpr> <xqx:functionCallExpr> <xqx:functionName>doc</xqx:functionName> <xqx:arguments> <xqx:stringConstantExpr> <xqx:value>http://bstore1.example.com/bib.xml</xqx:value> </xqx:stringConstantExpr> </xqx:arguments> </xqx:functionCallExpr> </xqx:filterExpr> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>descendant-or-self</xqx:xpathAxis> <xqx:anyKindTest/> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>child</xqx:xpathAxis> <xqx:nameTest>author</xqx:nameTest> </xqx:stepExpr> </xqx:pathExpr> </xqx:letExpr> </xqx:letClauseItem> </xqx:letClause> <xqx:forClause> <xqx:forClauseItem> <xqx:typedVariableBinding> <xqx:varName>last</xqx:varName> </xqx:typedVariableBinding> <xqx:forExpr> <xqx:functionCallExpr> <xqx:functionName>distinct-values</xqx:functionName> <xqx:arguments> <xqx:pathExpr> <xqx:stepExpr> <xqx:filterExpr> <xqx:varRef> <xqx:name>a</xqx:name> </xqx:varRef> </xqx:filterExpr> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>child</xqx:xpathAxis> <xqx:nameTest>last</xqx:nameTest> </xqx:stepExpr> </xqx:pathExpr> </xqx:arguments> </xqx:functionCallExpr> </xqx:forExpr> </xqx:forClauseItem> <xqx:forClauseItem> <xqx:typedVariableBinding> <xqx:varName>first</xqx:varName> </xqx:typedVariableBinding> <xqx:forExpr> <xqx:functionCallExpr> <xqx:functionName>distinct-values</xqx:functionName> <xqx:arguments> <xqx:pathExpr> <xqx:stepExpr> <xqx:filterExpr> <xqx:varRef> <xqx:name>a</xqx:name> </xqx:varRef> </xqx:filterExpr> <xqx:predicates> <xqx:equalOp> <xqx:firstOperand> <xqx:pathExpr> <xqx:stepExpr> <xqx:filterExpr> <xqx:contextItemExpr/> </xqx:filterExpr> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>child</xqx:xpathAxis> <xqx:nameTest>last</xqx:nameTest> </xqx:stepExpr> </xqx:pathExpr> </xqx:firstOperand> <xqx:secondOperand> <xqx:varRef> <xqx:name>last</xqx:name> </xqx:varRef> </xqx:secondOperand> </xqx:equalOp> </xqx:predicates> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>child</xqx:xpathAxis> <xqx:nameTest>first</xqx:nameTest> </xqx:stepExpr> </xqx:pathExpr> </xqx:arguments> </xqx:functionCallExpr> </xqx:forExpr> </xqx:forClauseItem> </xqx:forClause> <xqx:orderByClause> <xqx:orderBySpec> <xqx:orderByExpr> <xqx:varRef> <xqx:name>last</xqx:name> </xqx:varRef> </xqx:orderByExpr> </xqx:orderBySpec> <xqx:orderBySpec> <xqx:orderByExpr> <xqx:varRef> <xqx:name>first</xqx:name> </xqx:varRef> </xqx:orderByExpr> </xqx:orderBySpec> </xqx:orderByClause> <xqx:returnClause> <xqx:elementConstructor> <xqx:tagName>result</xqx:tagName> <xqx:elementContent> <xqx:elementConstructor> <xqx:tagName>author</xqx:tagName> <xqx:elementContent> <xqx:elementConstructor> <xqx:tagName>last</xqx:tagName> <xqx:elementContent> <xqx:varRef> <xqx:name>last</xqx:name> </xqx:varRef> </xqx:elementContent> </xqx:elementConstructor> <xqx:elementConstructor> <xqx:tagName>first</xqx:tagName> <xqx:elementContent> <xqx:varRef> <xqx:name>first</xqx:name> </xqx:varRef> </xqx:elementContent> </xqx:elementConstructor> </xqx:elementContent> </xqx:elementConstructor> <xqx:flworExpr> <xqx:forClause> <xqx:forClauseItem> <xqx:typedVariableBinding> <xqx:varName>b</xqx:varName> </xqx:typedVariableBinding> <xqx:forExpr> <xqx:pathExpr> <xqx:stepExpr> <xqx:filterExpr> <xqx:functionCallExpr> <xqx:functionName>doc</xqx:functionName> <xqx:arguments> <xqx:stringConstantExpr> <xqx:value>http://bstore1.example.com/bib.xml</xqx:value> </xqx:stringConstantExpr> </xqx:arguments> </xqx:functionCallExpr> </xqx:filterExpr> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>child</xqx:xpathAxis> <xqx:nameTest>bib</xqx:nameTest> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>child</xqx:xpathAxis> <xqx:nameTest>book</xqx:nameTest> </xqx:stepExpr> </xqx:pathExpr> </xqx:forExpr> </xqx:forClauseItem> </xqx:forClause> <xqx:whereClause> <xqx:quantifiedExpr> <xqx:quantifier>some</xqx:quantifier> <xqx:quantifiedExprInClause> <xqx:typedVariableBinding> <xqx:varName>ba</xqx:varName> </xqx:typedVariableBinding> <xqx:sourceExpr> <xqx:pathExpr> <xqx:stepExpr> <xqx:filterExpr> <xqx:varRef> <xqx:name>b</xqx:name> </xqx:varRef> </xqx:filterExpr> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>child</xqx:xpathAxis> <xqx:nameTest>author</xqx:nameTest> </xqx:stepExpr> </xqx:pathExpr> </xqx:sourceExpr> </xqx:quantifiedExprInClause> <xqx:predicateExpr> <xqx:andOp> <xqx:firstOperand> <xqx:equalOp> <xqx:firstOperand> <xqx:pathExpr> <xqx:stepExpr> <xqx:filterExpr> <xqx:varRef> <xqx:name>ba</xqx:name> </xqx:varRef> </xqx:filterExpr> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>child</xqx:xpathAxis> <xqx:nameTest>last</xqx:nameTest> </xqx:stepExpr> </xqx:pathExpr> </xqx:firstOperand> <xqx:secondOperand> <xqx:varRef> <xqx:name>last</xqx:name> </xqx:varRef> </xqx:secondOperand> </xqx:equalOp> </xqx:firstOperand> <xqx:secondOperand> <xqx:equalOp> <xqx:firstOperand> <xqx:pathExpr> <xqx:stepExpr> <xqx:filterExpr> <xqx:varRef> <xqx:name>ba</xqx:name> </xqx:varRef> </xqx:filterExpr> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>child</xqx:xpathAxis> <xqx:nameTest>first</xqx:nameTest> </xqx:stepExpr> </xqx:pathExpr> </xqx:firstOperand> <xqx:secondOperand> <xqx:varRef> <xqx:name>first</xqx:name> </xqx:varRef> </xqx:secondOperand> </xqx:equalOp> </xqx:secondOperand> </xqx:andOp> </xqx:predicateExpr> </xqx:quantifiedExpr> </xqx:whereClause> <xqx:returnClause> <xqx:pathExpr> <xqx:stepExpr> <xqx:filterExpr> <xqx:varRef> <xqx:name>b</xqx:name> </xqx:varRef> </xqx:filterExpr> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>child</xqx:xpathAxis> <xqx:nameTest>title</xqx:nameTest> </xqx:stepExpr> </xqx:pathExpr> </xqx:returnClause> </xqx:flworExpr> </xqx:elementContent> </xqx:elementConstructor> </xqx:returnClause> </xqx:flworExpr> </xqx:elementContent> </xqx:elementConstructor> </xqx:queryBody> </xqx:mainModule> </xqx:module> Application of the stylesheet in B Transforming XQueryX to XQuery <results>{ let $a:=doc("http://bstore1.example.com/bib.xml")/descendant-or-self::node()/child::author for $last in distinct-values($a/child::last), $first in distinct-values($a[(./child::last = $last)]/child::first) order by $last , $first return <result><author><last>{$last}</last><first>{$first}</first></author>{ for $b in doc("http://bstore1.example.com/bib.xml")/child::bib/child::book where (some $ba in $b/child::author satisfies (($ba/child::last = $last) and ($ba/child::first = $first))) return $b/child::title }</result> }</results> Here is Q7 from the [XQuery 3.0 Use Cases] <bib> { for $b in doc("http://bstore1.example.com/bib.xml")//book where $b/publisher = "Addison-Wesley" and $b/@year > 1991 order by $b/title return <book> { $b/@year } { $b/title } </book> } </bib> <?xml version="1.0"?> <xqx:module xmlns:xqx="http://www.w3.org/2005/XQueryX" 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"> <xqx:mainModule> <xqx:queryBody> <xqx:elementConstructor> <xqx:tagName>bib</xqx:tagName> <xqx:elementContent> <xqx:flworExpr> <xqx:forClause> <xqx:forClauseItem> <xqx:typedVariableBinding> <xqx:varName>b</xqx:varName> </xqx:typedVariableBinding> <xqx:forExpr> <xqx:pathExpr> <xqx:stepExpr> <xqx:filterExpr> <xqx:functionCallExpr> <xqx:functionName>doc</xqx:functionName> <xqx:arguments> <xqx:stringConstantExpr> <xqx:value>http://bstore1.example.com/bib.xml</xqx:value> </xqx:stringConstantExpr> </xqx:arguments> </xqx:functionCallExpr> </xqx:filterExpr> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>descendant-or-self</xqx:xpathAxis> <xqx:anyKindTest/> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>child</xqx:xpathAxis> <xqx:nameTest>book</xqx:nameTest> </xqx:stepExpr> </xqx:pathExpr> </xqx:forExpr> </xqx:forClauseItem> </xqx:forClause> <xqx:whereClause> <xqx:andOp> <xqx:firstOperand> <xqx:equalOp> <xqx:firstOperand> <xqx:pathExpr> <xqx:stepExpr> <xqx:filterExpr> <xqx:varRef> <xqx:name>b</xqx:name> </xqx:varRef> </xqx:filterExpr> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>child</xqx:xpathAxis> <xqx:nameTest>publisher</xqx:nameTest> </xqx:stepExpr> </xqx:pathExpr> </xqx:firstOperand> <xqx:secondOperand> <xqx:stringConstantExpr> <xqx:value>Addison-Wesley</xqx:value> </xqx:stringConstantExpr> </xqx:secondOperand> </xqx:equalOp> </xqx:firstOperand> <xqx:secondOperand> <xqx:greaterThanOp> <xqx:firstOperand> <xqx:pathExpr> <xqx:stepExpr> <xqx:filterExpr> <xqx:varRef> <xqx:name>b</xqx:name> </xqx:varRef> </xqx:filterExpr> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>attribute</xqx:xpathAxis> <xqx:nameTest>year</xqx:nameTest> </xqx:stepExpr> </xqx:pathExpr> </xqx:firstOperand> <xqx:secondOperand> <xqx:integerConstantExpr> <xqx:value>1991</xqx:value> </xqx:integerConstantExpr> </xqx:secondOperand> </xqx:greaterThanOp> </xqx:secondOperand> </xqx:andOp> </xqx:whereClause> <xqx:orderByClause> <xqx:orderBySpec> <xqx:orderByExpr> <xqx:pathExpr> <xqx:stepExpr> <xqx:filterExpr> <xqx:varRef> <xqx:name>b</xqx:name> </xqx:varRef> </xqx:filterExpr> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>child</xqx:xpathAxis> <xqx:nameTest>title</xqx:nameTest> </xqx:stepExpr> </xqx:pathExpr> </xqx:orderByExpr> </xqx:orderBySpec> </xqx:orderByClause> <xqx:returnClause> <xqx:elementConstructor> <xqx:tagName>book</xqx:tagName> <xqx:elementContent> <xqx:pathExpr> <xqx:stepExpr> <xqx:filterExpr> <xqx:varRef> <xqx:name>b</xqx:name> </xqx:varRef> </xqx:filterExpr> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>attribute</xqx:xpathAxis> <xqx:nameTest>year</xqx:nameTest> </xqx:stepExpr> </xqx:pathExpr> <xqx:pathExpr> <xqx:stepExpr> <xqx:filterExpr> <xqx:varRef> <xqx:name>b</xqx:name> </xqx:varRef> </xqx:filterExpr> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>child</xqx:xpathAxis> <xqx:nameTest>title</xqx:nameTest> </xqx:stepExpr> </xqx:pathExpr> </xqx:elementContent> </xqx:elementConstructor> </xqx:returnClause> </xqx:flworExpr> </xqx:elementContent> </xqx:elementConstructor> </xqx:queryBody> </xqx:mainModule> </xqx:module> Application of the stylesheet in B Transforming XQueryX to XQuery <bib>{ for $b in doc("http://bstore1.example.com/bib.xml")/descendant-or-self::node()/child::book where (($b/child::publisher = "Addison-Wesley") and ($b/attribute::year > 1991)) order by $b/child::title return <book>{$b/attribute::year}{$b/child::title}</book> }</bib> Here is Q8 from the [XQuery 3.0 Use Cases] declare namespace ma = "http://www.example.com/AuctionWatch"; <Q8 xmlns:ma="http://www.example.com/AuctionWatch" xmlns:eachbay="http://www.example.com/auctioneers#eachbay" xmlns:xlink="http://www.w3.org/1999/xlink"> { for $s in doc("auction.xml")//ma:Trading_Partners/(ma:Seller | ma:High_Bidder) where $s/*:NegativeComments = 0 return $s } </Q8> <?xml version="1.0"?> <!-- ================================================================================ --> <!-- Errata applied: --> <!-- XQX.E2 - Editorial (Bugzilla Bug 4963) --> <!-- ================================================================================ --> <xqx:module xmlns:xqx="http://www.w3.org/2005/XQueryX" 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"> <xqx:mainModule> <xqx:prolog> <xqx:namespaceDecl> <xqx:prefix>ma</xqx:prefix> <xqx:uri>http://www.example.com/AuctionWatch</xqx:uri> </xqx:namespaceDecl> </xqx:prolog> <xqx:queryBody> <xqx:elementConstructor> <xqx:tagName>Q8</xqx:tagName> <xqx:attributeList> <xqx:namespaceDeclaration> <xqx:prefix>ma</xqx:prefix> <xqx:uri>http://www.example.com/AuctionWatch</xqx:uri> </xqx:namespaceDeclaration> <xqx:namespaceDeclaration> <xqx:prefix>eachbay</xqx:prefix> <xqx:uri>http://www.example.com/auctioneers#eachbay</xqx:uri> </xqx:namespaceDeclaration> <xqx:namespaceDeclaration> <xqx:prefix>xlink</xqx:prefix> <xqx:uri>http://www.w3.org/1999/xlink</xqx:uri> </xqx:namespaceDeclaration> </xqx:attributeList> <xqx:elementContent> <xqx:flworExpr> <xqx:forClause> <xqx:forClauseItem> <xqx:typedVariableBinding> <xqx:varName>s</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>auction.xml</xqx:value> </xqx:stringConstantExpr> </xqx:arguments> </xqx:functionCallExpr> </xqx:filterExpr> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>descendant-or-self</xqx:xpathAxis> <xqx:anyKindTest/> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>child</xqx:xpathAxis> <xqx:nameTest xqx:prefix="ma">Trading_Partners</xqx:nameTest> </xqx:stepExpr> <xqx:stepExpr> <xqx:filterExpr> <xqx:sequenceExpr> <xqx:unionOp> <xqx:firstOperand> <xqx:pathExpr> <xqx:stepExpr> <xqx:xpathAxis>child</xqx:xpathAxis> <xqx:nameTest xqx:prefix="ma">Seller</xqx:nameTest> </xqx:stepExpr> </xqx:pathExpr> </xqx:firstOperand> <xqx:secondOperand> <xqx:pathExpr> <xqx:stepExpr> <xqx:xpathAxis>child</xqx:xpathAxis> <xqx:nameTest xqx:prefix="ma">High_Bidder</xqx:nameTest> </xqx:stepExpr> </xqx:pathExpr> </xqx:secondOperand> </xqx:unionOp> </xqx:sequenceExpr> </xqx:filterExpr> </xqx:stepExpr> </xqx:pathExpr> </xqx:forExpr> </xqx:forClauseItem> </xqx:forClause> <xqx:whereClause> <xqx:equalOp> <xqx:firstOperand> <xqx:pathExpr> <xqx:stepExpr> <xqx:filterExpr> <xqx:varRef> <xqx:name>s</xqx:name> </xqx:varRef> </xqx:filterExpr> </xqx:stepExpr> <xqx:stepExpr> <xqx:xpathAxis>child</xqx:xpathAxis> <xqx:Wildcard> <xqx:star/> <xqx:NCName>NegativeComments</xqx:NCName> </xqx:Wildcard> </xqx:stepExpr> </xqx:pathExpr> </xqx:firstOperand> <xqx:secondOperand> <xqx:integerConstantExpr> <xqx:value>0</xqx:value> </xqx:integerConstantExpr> </xqx:secondOperand> </xqx:equalOp> </xqx:whereClause> <xqx:returnClause> <xqx:varRef> <xqx:name>s</xqx:name> </xqx:varRef> </xqx:returnClause> </xqx:flworExpr> </xqx:elementContent> </xqx:elementConstructor> </xqx:queryBody> </xqx:mainModule> </xqx:module> Application of the stylesheet in B Transforming XQueryX to XQuery declare namespace ma="http://www.example.com/AuctionWatch"; <Q8 xmlns:ma="http://www.example.com/AuctionWatch" xmlns:eachbay="http://www.example.com/auctioneers#eachbay" xmlns:xlink="http://www.w3.org/1999/xlink">{ for $s in fn:doc("auction.xml")/descendant-or-self::node()/ child::ma:Trading_Partners/ ((child::ma:Seller union child::ma:High_Bidder)) where ($s/child::*:NegativeComments = 0) return $s }</Q8> Here is the XML Schema against which XQueryX documents must be valid. <!-- ================================================================================ --> <!-- NOTES TO READERS OF THIS SCHEMA: --> <!-- The default value for both minOccurs and maxOccurs is "1". --> <!-- The XQueryX schema has been designed to provide the ability to extend definitions --> <!-- of top-level elements in extensions such as Full-Text and the Update Facility. --> <!-- The nature of the modification is to define named complex types and redefine --> <!-- those top-level elements in terms of the named complex types. --> <!-- ================================================================================ --> <!-- Changes from Recommendation (edition 1): --> <!-- * Element defs using anon complex types changed to use named types (bug #4924) --> <!-- * In Example 4, replaced xqx:parentheziedExpr with xqx:sequenceExpr (bug #4963) --> <!-- * In XSLT stylesheet, deleted template for xqx:parenthesizedExpr (bug #4963) --> <!-- * Replaced link to grammar applet with correct link (bug #5323) --> <!-- * In XSLT stylesheet, corrected template for xqx:namespaceDeclaration (bug #5343) --> <!-- Changes from Recommendation (edition 2): --> <!-- * Added support for new Windowing clause in FLWOR expression --> <!-- * Added support for new Group By Clause in FLWOR expression --> <!-- * Added support for new Count Clause in FLWOR expression --> <!-- * Added support for keyword "outer" on for expression --> <!-- * Modified structure of FLWOR clause per "simplified FLWOR expressions" --> <!-- * Modified validation syntax per Bugzilla Bug 5472 --> <!-- * Modified function declaration so that external functions can be nondeterminstic --> <!-- * Modified variable declaration so external variables can have an initial value --> <!-- * Added support for new try-catch expression --> <!-- * Added support for new decimal formatting declaration --> <!-- * Added support for encoding in the version declaration --> <!-- * Added support for new context item declaration --> <!-- * Added support for computed namespace constructor --> <!-- * Made changes triggered by Bugzilla Bugs 6309, 6310, and 6311 --> <!-- * Modified errlist syntax per Bugzilla Bug 7053 --> <!-- * Added support for public/private functions --> <!-- * Replaced "outer for" support with support for "allowing empty" --> <!-- * Added support for higher-order functions --> <!-- * Added support for value-based "switch" expression --> <!-- * Use pattern to prohibit "#)" in pragma contents per Bugzilla Bug 2711 --> <!-- * Changed functionItemExpr child element QName to be functionName for consistency --> <!-- * Replaced "public", "private", and "[non]deterministic" with %-annotations --> <!-- * Added EQName to permit "URI-literal":NCNAME as alternative to NCName:NCName --> <!-- * Changed type of atomicType to EQName, so it's really atomicOrUnionType --> <!-- * Added simpleMapExpr and removed mapStepExpr (see bug 16197) --> <!-- ================================================================================ --> <!-- Errata applied: --> <!-- XQX.E1 - Editorial (Bugzilla Bug 4924) --> <!-- XQX.E7 - Substantive (Bugzilla Bug 2711) --> <!-- ================================================================================ --> <!-- Modifications: --> <!-- 2008-07-30 - Add XQuery 1.1 grouping and windowing support --> <!-- 2008-09-18 - Add XQuery 1.1 count and outer-for support, simplified FLWOR --> <!-- 2008-09-27 - Add validation type, nondeterministic function declarations, --> <!-- initial values for external variables, try-catch expression --> <!-- 2008-11-25 - Add support for number formatting, Snelson's version declaration --> <!-- proposal, context item declaration, computed namespace constructor,--> <!-- fixes for validate expression, and change to allow the count --> <!-- clause to only be an intermediate expression --> <!-- 2009-01-13 - Bugs 6309 and 6310 (fixes to details of certain windowing clauses --> <!-- 2009-03-03 - tumblingWindowClause syntax now matches slidingWindowClause syntax --> <!-- 2009-09-06 - Modified errlist syntax per Bugzilla Bug 7053 --> <!-- 2009-10-09 - Added support for private/public functions --> <!-- Replace "outer for" with "allowing empty" --> <!-- 2009-10-22 - Add support for higher-order functions & switch expression --> <!-- 2010-04-06 - Changed functionItemExpr child QName -> functionName (consistency) --> <!-- 2010-05-10 - Added %-annotation support for varDecl and functionDecl --> <!-- 2010-06-23 - Added support for partial function application --> <!-- 2011-02-02 - Added support for EQNames and atomicOrUnionType --> <!-- 2011-05-04 - Updated structure of catch component of try-catch expression --> <!-- 2011-05-04 - Updated validationexpr, mode/type alternatives, type is EQName --> <!-- 2011-07-08 - Added support for concatenation operator || --> <!-- * 2011-09-09 - Added support for simple mapping operator ! --> <!-- * 2011-09-09 - Added support for sequenceTypeUnion in typeswitch --> <!-- * 2011-09-09 - Added support for annotations on inline functions --> <!-- 2011-09-14 - Added support for new group-by syntax --> <!-- 2011-11-21 - Jim changed "literalFunctionItemExpr" to "namedFunctionRef" --> <!-- 2011-11-21 - Jim changed "inlineFunctionItemExpr" to "inlineFunctionExpr" --> <!-- 2012-06-15 - Added simpleMapExpr and removed mapStepExpr (see bug 16197) --> <!-- 2012-09-07 - Added %-annotation support for function tests --> <!-- 2012-09-07 - Added %-annotation support for function tests --> <!-- 2012-09-25 - Either version, encoding, or both are now required in versionDecl --> <!-- 2013-09-27 - Jim modified the definition of simpleMapExpr for multiple args --> <!-- ================================================================================ --> <xsd:complexType name="EQName"> <xsd:simpleContent> <xsd:extension base="xsd:NCName"> <xsd:attribute name="prefix" type="xsd:NCName" use="optional"/> <xsd:attribute name="URI" type="xsd:string" use="optional"/> </xsd:extension> </xsd:simpleContent> </xsd:complexType> <!-- A list of expressions or placeholders --> <!-- 2010-06-23 - Added support for partial function application --> <xsd:complexType name="exprOrPlaceholderList"> <xsd:sequence> <xsd:choice minOccurs="0" maxOccurs="unbounded"> <xsd:element ref="expr"/> <xsd:element name="argumentPlaceholder" type="emptyContent"/> </xsd:choice> </xsd:sequence> </xsd:complexType> <!-- A list of literals --> <!-- 2013-03-17 = Added new support for a list of literals, e.g., in annotations --> <xsd:complexType name="literalList"> <xsd:sequence> <xsd:element ref="constantExpr" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> <xsd:element name="name" type="EQName"/> <xsd:element name="pragmaName" type="EQName"/> <xsd:element name="pragmaContents"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:pattern value="(([^#]|#+[^\)#])*#*)"/> </xsd:restriction> </xsd:simpleType> </xsd:element> <!-- Simple map expressions --> <!-- 2012-06-15 - Changed precedence and precise grammar for simple map operator --> <!-- 2013-09-27 - Changed definition of simpleMapExpr to allow multiple path expressions--> <xsd:complexType name="simpleMapExpr"> <xsd:complexContent> <xsd:extension base="expr"> <xsd:sequence minOccurs="2" maxOccurs="unbounded"> <xsd:element ref="pathExpr"/> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType>
<xsd:element name="simpleMapExpr" type="simpleMapExpr" substitutionGroup="expr"/> <xsd:element name="functionName" type="EQName"/> <xsd:element name="arguments" type="exprOrPlaceholderList" minOccurs="0"/> <xsd:element name="typeName" type="EQName"/> <!-- String operator expressions --> <xsd:element name="stringOp" type="operatorExpr" abstract="true" substitutionGroup="operatorExpr"/>
<xsd:element name="stringConcatenateOp" type="binaryOperatorExpr" substitutionGroup="stringOp"/> <!-- By changing the type attribute from QName to EQName, this is now atomicOrUnionType --> <!-- However, for backwards compatibility w/XQueryX 1.0, the name had to stay the same--> <xsd:element name="atomicType" type="EQName" substitutionGroup="itemType"/> <xsd:complexType name="contextItemType"> <xsd:complexContent> <xsd:extension base="emptyItemTypeContent"> <xsd:sequence> <xsd:element ref="itemType"/> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType>
<xsd:element name="contextItemType" type="contextItemType" substitutionGroup="itemType"/> <!-- Union of sequence types --> <!-- 2011-09-09/JM - added a sequenceTypeUnion type --> <xsd:complexType name="sequenceTypeUnion"> <xsd:sequence minOccurs="1" maxOccurs="unbounded"> <xsd:element ref="sequenceType"/> </xsd:sequence> </xsd:complexType>
<xsd:element name="sequenceTypeUnion" type="sequenceTypeUnion"/> <xsd:element name="varName" type="EQName"/> <xsd:element name="positionalVariableBinding" type="EQName"/>
<xsd:element name="variableBinding" type="EQName"/> <xsd:element name="allowingEmpty" type="emptyContent" minOccurs="0"/> <!-- This is the windowClause (part of FLWOR expression) --> <!-- It corresponds to the following XQuery grammar --> <!-- WindowClause ::= "for" (TumblingWindowClause | SlidingWindowClause) --> <xsd:complexType name="windowClause"> <xsd:choice> <xsd:element ref="tumblingWindowClause"/> <xsd:element ref="slidingWindowClause"/> </xsd:choice> </xsd:complexType>
<xsd:element name="windowClause" type="windowClause"/>
<!-- This is the tumblingWindowClause --> <!-- It corresponds to the following XQuery grammar --> <!-- TumblingWindowClause ::= "tumbling" "window" "$" VarName TypeDeclaration? --> <!-- "in" ExprSingle WindowStartCondition WindowEndCondition? --> <xsd:complexType name="tumblingWindowClause"> <xsd:sequence> <xsd:element ref="typedVariableBinding"/> <xsd:element name="bindingSequence" type="exprWrapper"/> <xsd:element ref="windowStartCondition"/> <xsd:element ref="windowEndCondition" minOccurs="0"/> </xsd:sequence> </xsd:complexType>
<xsd:element name="tumblingWindowClause" type="tumblingWindowClause"/>
<!-- This is the slidingWindowClause --> <!-- It corresponds to the following XQuery grammar --> <!-- SlidingWindowClause ::= "sliding" "window" "$" VarName TypeDeclaration? --> <!-- "in" ExprSingle WindowStartCondition WindowEndCondition --> <xsd:complexType name="slidingWindowClause"> <xsd:sequence> <xsd:element ref="typedVariableBinding"/> <xsd:element name="bindingSequence" type="exprWrapper"/> <xsd:element ref="windowStartCondition"/> <xsd:element ref="windowEndCondition"/> </xsd:sequence> </xsd:complexType>
<xsd:element name="slidingWindowClause" type="slidingWindowClause"/>
<!-- windowStartCondition --> <!-- Corresponds to the following XQuery grammar --> <!-- WindowStartCondition ::= "start" WindowVars "when" ExprSingle --> <xsd:complexType name="windowStartCondition"> <xsd:sequence> <xsd:element ref="windowVars" minOccurs="0"/> <xsd:element name="winStartExpr" type="exprWrapper"/> </xsd:sequence> </xsd:complexType>
<xsd:element name="windowStartCondition" type="windowStartCondition"/>
<!-- windowEndCondition --> <!-- Corresponds to the following XQuery grammar --> <!-- WindowEndCondition ::= "only"? "end" WindowVars "when" ExprSingle --> <xsd:complexType name="windowEndCondition"> <xsd:sequence> <xsd:element ref="windowVars" minOccurs="0"/> <xsd:element name="winEndExpr" type="exprWrapper"/> </xsd:sequence> <xsd:attribute name="onlyEnd" type="xsd:boolean" default="false"/> </xsd:complexType>
<xsd:element name="windowEndCondition" type="windowEndCondition"/>
<!-- windowVars --> <!-- Corresponds to the following XQuery grammar --> <!-- WindowVars ::= ("$" \)? PositionalVar? ("previous" "$" PreviousItem)? --> <!-- ("next" "$" NextItem)? --> <xsd:complexType name="windowVars"> <xsd:sequence> <xsd:element name="currentItem" type="EQName" minOccurs="0"/> <xsd:element ref="positionalVariableBinding" minOccurs="0"/> <xsd:element name="previousItem" type="EQName" minOccurs="0"/> <xsd:element name="nextItem" type="EQName" minOccurs="0"/> </xsd:sequence> </xsd:complexType>
<xsd:element name="windowVars" type="windowVars"/>
<!-- countClause (part of FLWOR expression) --> <xsd:complexType name="countClause"> <xsd:sequence> <xsd:element ref="varRef"/> </xsd:sequence> </xsd:complexType>
<xsd:element name="countClause" type="countClause"/> <!-- groupByClause (part of FLWOR expression) --> <!-- Corresponds to the following XQuery syntax --> <!-- GroupByClause ::= "group" "by" GroupingSpecList --> <!-- GroupingSpecList ::= GroupingSpec ("," GroupingSpec)* --> <xsd:complexType name="groupByClause"> <xsd:sequence maxOccurs="unbounded"> <xsd:element ref="groupingSpec"/> </xsd:sequence> </xsd:complexType>
<xsd:element name="groupByClause" type="groupByClause"/>
<!-- 2011-09-14/JM - added the ability to initialize a grouping variable, opt set type --> <!-- Corresponds to the following XQuery syntax --> <!-- GroupingSpec ::= --> <!-- "$" VarName ( typeDeclaration? ":=" exprSingle )? ("collation" URILiteral)? --> <xsd:complexType name="groupingSpec"> <xsd:sequence> <xsd:element name="varName" type="EQName"/> <xsd:element name="groupVarInitialize" minOccurs="0"> <xsd:complexType> <xsd:sequence> <xsd:element ref="typeDeclaration" minOccurs="0"/> <xsd:element name="varValue" type="exprWrapper"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="collation" type="xsd:string" minOccurs="0"/> </xsd:sequence> </xsd:complexType>
<xsd:element name="groupingSpec" type="groupingSpec"/> <!-- This is the XQuery 3.0 flwor expression --> <!-- Corresponds to the following XQuery syntax: --> <!-- 1.1 FLWORExpr ::= (ForClause | LetClause | WindowClause) --> <!-- (ForClause | LetClause | WindowClause | CountClause | --> <!-- WhereClause | GroupByClause | OrderByClause)* --> <!-- ReturnClause --> <xsd:complexType name="flworExpr"> <xsd:complexContent> <xsd:extension base="expr"> <xsd:sequence> <xsd:choice> <xsd:element ref="forClause"/> <xsd:element ref="letClause"/> <xsd:element ref="windowClause"/> </xsd:choice> <xsd:sequence> <xsd:choice minOccurs="0" maxOccurs="unbounded"> <xsd:element ref="forClause"/> <xsd:element ref="letClause"/> <xsd:element ref="windowClause"/> <xsd:element ref="countClause"/> <xsd:element ref="whereClause"/> <xsd:element ref="groupByClause"/> <xsd:element ref="orderByClause"/> </xsd:choice> <xsd:element ref="returnClause"/> </xsd:sequence> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType> <!-- handle the switch expression --> <!-- Note: no substitutionGroup as we cannot use this anywhere except within switch --> <xsd:complexType name="switchExprCaseClause"> <xsd:complexContent> <xsd:extension base="expr"> <xsd:sequence> <xsd:element name="switchCaseExpr" type="exprWrapper" maxOccurs="unbounded"/> <xsd:element name="resultExpr" type="exprWrapper"/> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType>
<xsd:element name="switchExprCaseClause" type="switchExprCaseClause"/>
<!-- Note: no substitutionGroup as we cannot use this anywhere except within switch --> <xsd:complexType name="switchExprDefaultClause"> <xsd:complexContent> <xsd:extension base="expr"> <xsd:sequence> <xsd:element name="resultExpr" type="exprWrapper"/> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType>
<xsd:element name="switchExprDefaultClause" type="switchExprDefaultClause"/>
<xsd:complexType name="switchExpr"> <xsd:complexContent> <xsd:extension base="expr"> <xsd:sequence> <xsd:element name="argExpr" type="exprWrapper"/> <xsd:element ref="switchExprCaseClause" maxOccurs="unbounded"/> <xsd:element ref="switchExprDefaultClause"/> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType>
<xsd:element name="switchExpr" type="switchExpr" substitutionGroup="expr"/> <xsd:choice> <xsd:element ref="sequenceType"/> <xsd:element ref="sequenceTypeUnion"/> </xsd:choice> <!-- TryCatchExpression --> <!-- Corresponds to the following XQuery syntax --> <!-- TryCatchExpression ::= TryClause CatchClause+ --> <!-- TryClause ::= "{" TryTargetExpr "}" --> <!-- TryTargetExpr ::= Expr --> <xsd:complexType name="tryCatchExpr"> <xsd:complexContent> <xsd:extension base="expr"> <xsd:sequence> <xsd:element name="tryClause" type="exprWrapper"/> <xsd:element ref="catchClause" maxOccurs="unbounded"/> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType>
<xsd:element name="tryCatchExpr" type="tryCatchExpr" substitutionGroup="expr"/>
<!-- CatchClause (part of the TryCatchExpression) --> <!-- Corresponds to the following XQuery syntax --> <!-- CatchClause ::= "catch" CatchErrorList "{" Expr "}" --> <xsd:complexType name="catchClause"> <xsd:sequence> <xsd:element ref="catchErrorList"/> <xsd:element name="catchExpr" type="exprWrapper"/> </xsd:sequence> </xsd:complexType>
<xsd:element name="catchClause" type="catchClause"/>
<!-- CatchErrorList (part of the TryCatchExpression) --> <!-- Corresponds to the following XQuery syntax --> <!-- CatchErrorList ::= NameTest ( "|" NameTest )* --> <!-- (remembering that NameTest is either QName or Wildcard) --> <xsd:complexType name="catchErrorList"> <xsd:sequence maxOccurs="unbounded"> <xsd:choice> <xsd:element ref="nameTest"/> <xsd:element ref="Wildcard"/> </xsd:choice> </xsd:sequence> </xsd:complexType>
<xsd:element name="catchErrorList" type="catchErrorList"/> <xsd:choice> <xsd:element name="validationMode" type="validationMode" minOccurs="0"/> <xsd:element name="typeName" type="EQName" minOccurs="0"/> </xsd:choice> <xsd:element name="tagName" type="EQName"/> <xsd:element name="tagName" type="EQName"/> <!-- computed namespace constructor --> <xsd:complexType name="computedNamespaceConstructor"> <xsd:complexContent> <xsd:extension base="expr"> <xsd:sequence> <xsd:choice> <xsd:element name="prefix" type="xsd:NCName"/> <xsd:element name="prefixExpr" type="exprWrapper"/> </xsd:choice> <xsd:element name="URIExpr" type="exprWrapper" minOccurs="0"/> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType>
<xsd:element name="computedNamespaceConstructor" type="computedNamespaceConstructor" substitutionGroup="expr"/> <!-- function item expressions --> <!-- literal function item expression --> <!-- 2010-04-06: Jim changed child element QName to be functionName for consistency --> <!-- 2011-11-21: Jim changed "literalFunctionItemExpr" to "namedFunctionRef" --> <xsd:complexType name="namedFunctionRef"> <xsd:complexContent> <xsd:extension base="expr"> <xsd:sequence> <xsd:element name="functionName" type="EQName"/> <xsd:element name="integerConstantExpr" type="integerConstantExpr"/> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType>
<xsd:element name="namedFunctionRef" type="namedFunctionRef" substitutionGroup="expr"/>
<!-- inline function item expression --> <!-- 2011-09-09/JM - Added annotations to inline functions --> <!-- 2011-11-21: Jim changed "inlineFunctionItemExpr" to "inlineFunctionExpr" --> <xsd:complexType name="inlineFunctionExpr"> <xsd:complexContent> <xsd:extension base="expr"> <xsd:sequence> <xsd:element name="annotation" type="annotation" minOccurs="0" maxOccurs="unbounded"/> <xsd:element ref="paramList"/> <xsd:element ref="typeDeclaration" minOccurs="0"/> <xsd:element name="functionBody" type="exprWrapper"/> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType>
<xsd:element name="inlineFunctionExpr" type="inlineFunctionExpr" substitutionGroup="expr"/>
<!-- dynamic function invocations --> <!-- 2010-06-23 - Added support for partial function application --> <xsd:complexType name="dynamicFunctionInvocationExpr"> <xsd:complexContent> <xsd:extension base="expr"> <xsd:sequence> <xsd:element name="functionItem"> <xsd:complexType> <xsd:sequence> <xsd:group ref="filterExpr"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="predicates" type="exprList" minOccurs="0"/> <xsd:element name="arguments" type="exprOrPlaceholderList" minOccurs="0"/> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType>
<xsd:element name="dynamicFunctionInvocationExpr" type="dynamicFunctionInvocationExpr" substitutionGroup="expr"/> <xsd:element name="QName" type="EQName"/> <xsd:choice minOccurs="0"> <xsd:sequence> <xsd:element name="star" type="emptyContent"/> <xsd:element ref="NCName"/> </xsd:sequence> <xsd:sequence> <xsd:element ref="NCName"/> <xsd:element name="star" type="emptyContent"/> </xsd:sequence> <xsd:sequence> <xsd:element name="uri" type="xsd:string"/> <xsd:element name="star" type="emptyContent"/> </xsd:sequence> </xsd:choice> <xsd:element name="schemaAttributeTest" type="EQName" substitutionGroup="kindTest"/> <xsd:element name="typeName" type="EQName" minOccurs="0"/> <xsd:element name="schemaElementTest" type="EQName" substitutionGroup="anyElementTest"/> <xsd:element name="typeName" type="EQName"/> <xsd:element name="nameTest" type="EQName"/> <xsd:element name="namespaceTest" type="emptyItemTypeContent" substitutionGroup="kindTest"/> <!-- functionTest variations --> <!-- 2012-09-07: Jim added annotation support --> <xsd:complexType name="anyFunctionTest"> <xsd:complexContent> <xsd:extension base="emptyItemTypeContent"> <xsd:sequence> <xsd:element name="annotation" type="annotation" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType>
<xsd:element name="anyFunctionTest" type="anyFunctionTest" substitutionGroup="itemType"/>
<!-- 2012-09-07: Jim added annotation support --> <xsd:complexType name="typedFunctionTest"> <xsd:complexContent> <xsd:extension base="emptyItemTypeContent"> <xsd:sequence> <xsd:element name="annotation" type="annotation" minOccurs="0" maxOccurs="unbounded"/> <xsd:element ref="paramTypeList" minOccurs="0"/> <xsd:element ref="sequenceType"/> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType>
<xsd:element name="typedFunctionTest" type="typedFunctionTest" substitutionGroup="itemType"/>
<xsd:complexType name="paramTypeList"> <xsd:sequence> <xsd:element ref="sequenceType" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType>
<xsd:element name="paramTypeList" type="paramTypeList"/>
<xsd:complexType name="parenthesizedItemType"> <xsd:complexContent> <xsd:extension base="emptyItemTypeContent"> <xsd:sequence> <xsd:element ref="itemType"/> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType>
<xsd:element name="parenthesizedItemType" type="parenthesizedItemType" substitutionGroup="itemType"/> <!-- 2011-11-21: Jim changed "literalFunctionItemExpr" to "namedFunctionRef" --> <!-- 2011-11-21: Jim changed "inlineFunctionItemExpr" to "inlineFunctionExpr" --> <xsd:element ref="namedFunctionRef"/> <xsd:element ref="inlineFunctionExpr"/> <xsd:element ref="dynamicFunctionInvocationExpr"/> <xsd:choice> <xsd:sequence> <xsd:element name="version" type="xsd:string"/> <xsd:element name="encoding" type="xsd:string" minOccurs="0"/> </xsd:sequence> <xsd:element name="encoding" type="xsd:string"/> </xsd:choice> <xsd:simpleType name="boundarySpaceDecl"> <xsd:restriction base="xsd:NMTOKEN"> <xsd:enumeration value="strip"/> <xsd:enumeration value="preserve"/> </xsd:restriction> </xsd:simpleType>
<xsd:element name="boundarySpaceDecl" type="boundarySpaceDecl" substitutionGroup="prologPartOneItem"/>
<xsd:element name="defaultCollationDecl" type="xsd:string" substitutionGroup="prologPartOneItem"/>
<xsd:element name="baseUriDecl" type="xsd:string" substitutionGroup="prologPartOneItem"/> <xsd:complexType name="decimalFormatDeclType"> <xsd:sequence> <xsd:element name="decimalFormatName" type="EQName" minOccurs="0"/> <xsd:element name="decimalFormatParam" minOccurs="0" maxOccurs="unbounded"> <xsd:complexType> <xsd:sequence> <xsd:element name="decimalFormatParamName"> <xsd:simpleType> <xsd:restriction base="xsd:NMTOKEN"> <xsd:enumeration value="decimal-separator"/> <xsd:enumeration value="grouping-separator"/> <xsd:enumeration value="infinity"/> <xsd:enumeration value="minus-sign"/> <xsd:enumeration value="NaN"/> <xsd:enumeration value="percent"/> <xsd:enumeration value="per-mille"/> <xsd:enumeration value="zero-digit"/> <xsd:enumeration value="digit"/> <xsd:enumeration value="pattern-separator"/> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="decimalFormatParamValue" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType>
<xsd:element name="decimalFormatDecl" type="decimalFormatDeclType" substitutionGroup="prologPartOneItem"/> <xsd:complexType name="contextItemDecl"> <xsd:sequence> <xsd:element ref="contextItemType" minOccurs="0"/> <xsd:choice> <xsd:element name="varValue" type="exprWrapper"/> <xsd:sequence> <xsd:element name="external"> <xsd:complexType> <xsd:sequence> <xsd:element name="varValue" type="exprWrapper" minOccurs="0"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:choice> </xsd:sequence> </xsd:complexType>
<xsd:element name="contextItemDecl" type="contextItemDecl" substitutionGroup="prologPartTwoItem"/>
<!-- For %-annotations --> <!-- 2013-03-17 - Added new support for a list of literals --> <xsd:complexType name="annotation"> <xsd:sequence> <xsd:element name="annotationName" type="EQName"/> <xsd:element name="arguments" type="literalList" minOccurs="0"/> </xsd:sequence> </xsd:complexType> <xsd:element name="annotation" type="annotation" minOccurs="0" maxOccurs="unbounded"/> <xsd:element name="varName" type="EQName"/> <xsd:element ref="typeDeclaration" minOccurs="0"/> <xsd:choice> <xsd:element name="varValue" type="exprWrapper"/> <xsd:sequence> <xsd:element name="external"> <xsd:complexType> <xsd:sequence> <xsd:element name="varValue" type="exprWrapper" minOccurs="0"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:choice> <xsd:element name="optionName" type="EQName"/> <xsd:element name="annotation" type="annotation" minOccurs="0" maxOccurs="unbounded"/> <xsd:element name="functionName" type="EQName"/> <xsd:element ref="paramList"/> <xsd:element ref="typeDeclaration" minOccurs="0"/> <xsd:choice> <xsd:element name="functionBody" type="exprWrapper"/> <xsd:element name="externalDefinition" type="emptyContent"/> </xsd:choice> </xsd:sequence> <xsd:element name="varName" type="EQName"/> This section defines the conformance criteria for an XQueryX processor (see Figure 1, "Processing Model Overview", in [XQuery 3.0: An XML Query Language] Section 2.2 Processing Model XQ30 In this section, the following terms are used to indicate the requirement levels defined in [RFC 2119] An XQueryX processor that claims to conform to this specification MUST implement the XQueryX syntax as defined in 4 An XML Schema for the XQuery XML Syntax [XQuery 3.0: An XML Query Language] Section 5.1 Minimal Conformance XQ30 [XQuery 3.0: An XML Query Language] Section 5.2 Optional Features XQ30 XML Syntax for XQuery 1.0 (XQueryX) (Second Edition) latest version XQuery 3.0 Requirements latest version XQuery 3.0: An XML Query Language latest version XQuery 3.0 Use Cases latest version XQuery 1.0 and XPath 2.0 Formal Semantics (Second Edition) et. al. latest version S. Bradner. Key Words for use in RFCs to Indicate Requirement Levels. http://www.ietf.org/rfc/rfc2119.txt M. Murata, S. St. Laurent, and D. Kohn. XML Media Types http://www.ietf.org/rfc/rfc3023.txt The following stylesheet converts from XQueryX syntax to XML Query syntax. Note the intent of the stylesheet is to produce a [XQuery 1.0 and XPath 2.0 Formal Semantics] <!-- ================================================================================ --> <!-- Changes from Recommendation (edition 1): --> <!-- * In XSLT stylesheet, deleted template for xqx:parenthesizedExpr (bug #4963) --> <!-- * In XSLT stylesheet, corrected template for xqx:namespaceDeclaration (bug #5343) --> <!-- Changes from Recommendation (edition 2): --> <!-- * Added support for new Windowing clause in FLWOR expression --> <!-- * Added support for new Group By Clause in FLWOR expression --> <!-- * Added support for new Count Clause in FLWOR expression --> <!-- * Added support for keyword "outer" on for expression --> <!-- * Modified structure of FLWOR clause per "simplified FLWOR expressions" --> <!-- * Modified validation syntax per Bugzilla Bug 5472 --> <!-- * Modified function declaration so that external functions can be nondeterminstic --> <!-- * Modified variable declaration so external variables can have an initial value --> <!-- * Added support for new try-catch expression --> <!-- * Made changes triggered by Bugzilla Bugs 6309, 6310, and 6311 --> <!-- * Modified errlist syntax per Bugzilla Bug 7053 --> <!-- * Added support for public/private functions --> <!-- * Replaced "outer for" support with support for "allowing empty" --> <!-- * Added support for higher-order functions --> <!-- * Added support for value-based "switch" expression --> <!-- * Changed functionItemExpr child element QName to be functionName for consistency --> <!-- * Added simpleMapExpr and removed mapStepExpr (see bug 16197) --> <!-- ================================================================================ --> <!-- Errata applied: --> <!-- XQX.E3 - Editorial (Bugzilla Bug 4963) --> <!-- XQX.E5 - Editorial (Bugzilla Bug 5343) --> <!-- XQX.E9 - Minor technical (Bugzilla Bug 6733) --> <!-- ================================================================================ --> <!-- Modifications: --> <!-- 2008-07-30 - Add XQuery 1.1 grouping and windowing support --> <!-- 2008-09-18 - Add XQuery 1.1 count and outer-for support, simplified FLWOR --> <!-- 2008-09-27 - Add validation type, nondeterministic function declarations, --> <!-- initial values for external variables, try-catch expressions --> <!-- 2008-11-14 - Add decimal formatting decl, encoding for version decl, --> <!-- context item decl, computed namespace constructor --> <!-- 2008-11-25 - Add support for fixes for validate expression, and change to allow --> <!-- the count clause to only be an intermediate expression --> <!-- 2009-01-13 - Bugs 6309 and 6310 (fixes to details of certain windowing clauses --> <!-- 2009-03-03 - tumblingWindowClause syntax now matches slidingWindowClause syntax --> <!-- 2009-09-06 - Modified errlist syntax per Bugzilla Bug 7053 --> <!-- 2009-10-09 - Added support for private/public functions --> <!-- Replace "outer for" with "allowing empty" --> <!-- 2009-10-22 - Add support for higher-order functions & switch expression --> <!-- 2010-01-06 - Omit parens when following-sibling of rootExpr is stepExpr --> <!-- 2010-04-06 - Changed functionItemExpr child QName -> functionName (consistency) --> <!-- 2010-06-23 - Added support for partial function application --> <!-- 2011-05-04 - Updated structure of catch component of try-catch expression --> <!-- 2011-05-04 - Updated validationexpr, mode/type alternatives, type is EQName --> <!-- 2011-05-31 - Fixed functionItemExpr and functionCallExpr re: unqualified names --> <!-- 2011-07-08 - Added support for concatenation operator || --> <!-- 2011-09-09 - Added support for simple mapping operator ! --> <!-- 2011-09-09 - Added support for sequenceTypeUnion in typeswitch --> <!-- 2011-09-09 - Added support for annotations on inline functions --> <!-- 2011-09-14 - Added support for new group-by syntax --> <!-- 2011-11-21 - Jim changed "literalFunctionItemExpr" to "namedFunctionRef" --> <!-- 2011-11-21 - Jim changed "inlineFunctionItemExpr" to "inlineFunctionExpr" --> <!-- 2012-02-24 - Jim updated EQname template to generate revised XQuery syntax --> <!-- 2012-06-15 - Added simpleMapExpr and removed mapStepExpr (see bug 16197) --> <!-- 2012-06-22 - Generate parentheses surrounding try-catch expressions (bug 17549) --> <!-- 2012-09-07 - Added %-annotation support for function tests --> <!-- 2012-09-25 - If encoding is specified in versionDecl, the generated XQ uses it --> <!-- 2013-09-27 - Modified schema definition of simpleMapExpr for multiple arguments --> <!-- ================================================================================ --> <xsl:variable name="EXCLAMATIONMARK" select="'!'"/> <xsl:variable name="PERCENT" select="'%'"/> <xsl:variable name="CONCATENATE" select="'||'"/> <xsl:template name="renderQName"> <xsl:if test="@xqx:prefix"> <xsl:value-of select="@xqx:prefix"/> <xsl:value-of select="$COLON"/> </xsl:if> <xsl:value-of select="."/> </xsl:template> <!-- 2012-02-24 - Changed output generated when URI is given instead of prefix --> <xsl:template name="renderEQName" match="xqx:QName | xqx:pragmaName | xqx:typeName | xqx:varName | xqx:functionName | xqx:optionName | xqx:annotationName | xqx:atomicType | xqx:tagName | xqx:name | xqx:decimalFormatName"> <xsl:choose> <xsl:when test="xqx:tagName/parent::xqx:elementConstructor"> <xsl:call-template name="renderQName"/> </xsl:when> <xsl:otherwise> <xsl:choose> <xsl:when test="@xqx:prefix and @xqx:URI"> <xsl:message terminate="yes">Incorrect XQueryX: Elements of type xqx:EQName must not have both 'prefix' and 'URI' attributes</xsl:message> </xsl:when> <xsl:when test="@xqx:prefix"> <xsl:value-of select="@xqx:prefix"/> <xsl:value-of select="$COLON"/> <xsl:value-of select="."/> </xsl:when> <xsl:when test="@xqx:URI"> <xsl:text>Q</xsl:text> <xsl:value-of select="$LBRACE"/> <xsl:value-of select="@xqx:URI"/> <xsl:value-of select="$RBRACE"/> <xsl:value-of select="."/> </xsl:when> <xsl:otherwise> <xsl:value-of select="."/> </xsl:otherwise> </xsl:choose> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:when test=". = 'xmlns'"> <xsl:message terminate="yes">Incorrect XQueryX: Attribute names are not permitted to be 'xmlns'; use xqx:namespaceDeclaration to declare namespaces</xsl:message> </xsl:when> <xsl:otherwise> <xsl:call-template name="renderQName"/> </xsl:otherwise> <!-- 2010-06-23 - Added support for partial function application --> <xsl:template match="xqx:argumentPlaceholder"> <xsl:value-of select="$QUESTIONMARK"/> </xsl:template>
<!-- To resolve Bugzilla bug #6733, we now treat a rootExpr child of pathExpr distinctly from a rootExpr that occurs in other contexts, transforming it to "(/)" as proper XQuery grammar. There is an additional consideration on this: If the immediately following sibling of rootExpr is a stepExpr, then the parens must be omitted. --> <xsl:template match="xqx:pathExpr/xqx:rootExpr"> <xsl:if test="not(following-sibling::xqx:stepExpr)"> <xsl:value-of select="$LPAREN"/> </xsl:if> <xsl:value-of select="$SPACE"/> <xsl:value-of select="$SLASH"/> <xsl:value-of select="$SPACE"/> <xsl:if test="not(following-sibling::xqx:stepExpr)"> <xsl:value-of select="$RPAREN"/> </xsl:if> </xsl:template> <xsl:apply-templates select="xqx:name"/> <!-- 2012-06-15 - Jim added simpleMapExpr --> <!-- 2013-09-27 - Jim modified definition of simpleMapExpr --> <xsl:template match="xqx:simpleMapExpr"> <xsl:value-of select="$LPAREN"/> <xsl:value-of select="$SPACE"/> <xsl:apply-templates select="xqx:pathExpr[1]"/> <xsl:value-of select="$SPACE"/> <xsl:value-of select="$RPAREN"/> <xsl:for-each select="xqx:pathExpr[position() != 1]"> <xsl:value-of select="$NEWLINE"/> <xsl:value-of select="$EXCLAMATIONMARK"/> <xsl:value-of select="$SPACE"/> <xsl:value-of select="$LPAREN"/> <xsl:value-of select="$SPACE"/> <xsl:apply-templates select="."/> <xsl:value-of select="$SPACE"/> <xsl:value-of select="$RPAREN"/> </xsl:for-each> </xsl:template> <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:apply-templates select="xqx:functionName"/> <xsl:template match="xqx:stringConcatenateOp"> <xsl:value-of select="$LPAREN"/> <xsl:apply-templates select="xqx:firstOperand"/> <xsl:value-of select="$CONCATENATE"/> <xsl:apply-templates select="xqx:secondOperand"/> <xsl:value-of select="$RPAREN"/> </xsl:template> <xsl:template match="xqx:allowingEmpty"> <xsl:text> allowing empty </xsl:text> </xsl:template> <xsl:template match="xqx:windowClause"> <xsl:text> for </xsl:text> <xsl:apply-templates/> <xsl:value-of select="$NEWLINE"/> </xsl:template>
<xsl:template match="xqx:tumblingWindowClause"> <xsl:text> tumbling window </xsl:text> <xsl:apply-templates select="xqx:typedVariableBinding"/> <xsl:text> in </xsl:text> <xsl:apply-templates select="xqx:bindingSequence"/> <xsl:value-of select="$NEWLINE"/> <xsl:text> </xsl:text> <xsl:apply-templates select="xqx:windowStartCondition"/> <xsl:value-of select="$NEWLINE"/> <xsl:text> </xsl:text> <xsl:apply-templates select="xqx:windowEndCondition"/> </xsl:template>
<xsl:template match="xqx:slidingWindowClause"> <xsl:text> sliding window </xsl:text> <xsl:apply-templates select="xqx:typedVariableBinding"/> <xsl:text> in </xsl:text> <xsl:apply-templates select="xqx:bindingSequence"/> <xsl:value-of select="$NEWLINE"/> <xsl:text> </xsl:text> <xsl:apply-templates select="xqx:windowStartCondition"/> <xsl:value-of select="$NEWLINE"/> <xsl:text> </xsl:text> <xsl:apply-templates select="xqx:windowEndCondition"/> </xsl:template>
<xsl:template match="xqx:bindingSequence"> <xsl:apply-templates/> </xsl:template>
<xsl:template match="xqx:windowStartCondition"> <xsl:text>start </xsl:text> <xsl:apply-templates select="xqx:windowVars"/> <xsl:text> when </xsl:text> <xsl:apply-templates select="xqx:winStartExpr"/> </xsl:template>
<xsl:template match="xqx:windowEndCondition"> <xsl:if test="@xqx:onlyEnd='true'"> <xsl:text>only </xsl:text> </xsl:if> <xsl:text>end </xsl:text> <xsl:apply-templates select="xqx:windowVars"/> <xsl:text> when </xsl:text> <xsl:apply-templates select="xqx:winEndExpr"/> </xsl:template>
<xsl:template match="xqx:windowVars"> <xsl:apply-templates select="xqx:currentItem"/> <xsl:apply-templates select="xqx:positionalVariableBinding"/> <xsl:apply-templates select="xqx:previousItem"/> <xsl:apply-templates select="xqx:nextItem"/> </xsl:template>
<xsl:template match="xqx:currentItem"> <xsl:value-of select="$DOLLAR"/> <xsl:call-template name="renderEQName"/> </xsl:template>
<xsl:template match="xqx:previousItem"> <xsl:text> previous </xsl:text> <xsl:value-of select="$DOLLAR"/> <xsl:call-template name="renderEQName"/> </xsl:template>
<xsl:template match="xqx:nextItem"> <xsl:text> next </xsl:text> <xsl:value-of select="$DOLLAR"/> <xsl:call-template name="renderEQName"/> </xsl:template>
<xsl:template match="xqx:countClause"> <xsl:text> count </xsl:text> <xsl:apply-templates/> <xsl:value-of select="$NEWLINE"/> </xsl:template> <xsl:template match="xqx:groupByClause"> <xsl:text> group by </xsl:text> <xsl:call-template name="commaSeparatedList"/> <xsl:value-of select="$NEWLINE"/> </xsl:template>
<xsl:template match="xqx:groupingSpec"> <xsl:value-of select="$DOLLAR"/> <xsl:apply-templates/> </xsl:template>
<!-- 2011-09-14/JM - added the ability to initialize a grouping variable, opt set type --> <xsl:template match="xqx:groupVarInitialize"> <xsl:if test="xqx:typeDeclaration"> <xsl:apply-templates select="xqx:typeDeclaration"/> </xsl:if> <xsl:value-of select="$SPACE"/> <xsl:value-of select="$ASSIGN"/> <xsl:value-of select="$SPACE"/> <xsl:apply-templates select="xqx:varValue"/> </xsl:template> <xsl:call-template name="renderEQName"/> <xsl:call-template name="renderEQName"/> <xsl:template match="xqx:switchExprCaseClause"> <xsl:for-each select="xqx:switchCaseExpr"> <xsl:value-of select="$NEWLINE"/> <xsl:text> case (</xsl:text> <xsl:apply-templates select="."/> <xsl:text>) </xsl:text> </xsl:for-each> <xsl:value-of select="$NEWLINE"/> <xsl:text> return </xsl:text> <xsl:apply-templates select="xqx:resultExpr"/> </xsl:template>
<xsl:template match="xqx:switchExprDefaultClause"> <xsl:value-of select="$NEWLINE"/> <xsl:text> default return </xsl:text> <xsl:apply-templates select="xqx:resultExpr"/> </xsl:template>
<xsl:template match="xqx:switchExpr"> <xsl:value-of select="$LPAREN"/> <xsl:text>switch</xsl:text> <xsl:value-of select="$LPAREN"/> <xsl:apply-templates select="xqx:argExpr"/> <xsl:value-of select="$RPAREN"/> <xsl:apply-templates select="xqx:switchExprCaseClause"/> <xsl:apply-templates select="xqx:switchExprDefaultClause"/> <xsl:value-of select="$RPAREN"/> </xsl:template> <xsl:apply-templates select="xqx:sequenceType | xqx:sequenceTypeUnion"/> <xsl:template match="xqx:tryCatchExpr"> <xsl:value-of select="$NEWLINE"/> <xsl:value-of select="$LPAREN"/> <xsl:text>try </xsl:text> <xsl:apply-templates select="xqx:tryClause"/> <xsl:apply-templates select="xqx:catchClause"/> <xsl:value-of select="$RPAREN"/> </xsl:template>
<xsl:template match="xqx:tryClause"> <xsl:value-of select="$LBRACE"/> <xsl:value-of select="$SPACE"/> <xsl:apply-templates/> <xsl:value-of select="$SPACE"/> <xsl:value-of select="$RBRACE"/> </xsl:template>
<xsl:template match="xqx:catchClause"> <xsl:value-of select="$NEWLINE"/> <xsl:text> catch </xsl:text> <xsl:apply-templates select="xqx:catchErrorList"/> <xsl:apply-templates select="xqx:catchExpr"/> </xsl:template>
<xsl:template match="xqx:catchErrorList"> <xsl:for-each select="xqx:nameTest | xqx:Wildcard"> <xsl:if test="(position() mod 5) = 0"> <xsl:value-of select="$NEWLINE"/> <xsl:text> </xsl:text> </xsl:if> <xsl:if test="position() > 1"> <xsl:text>| </xsl:text> </xsl:if> <xsl:apply-templates select="."/> <xsl:value-of select="$SPACE"/> </xsl:for-each> </xsl:template>
<xsl:template match="xqx:catchExpr"> <xsl:value-of select="$NEWLINE"/> <xsl:value-of select="$LBRACE"/> <xsl:value-of select="$SPACE"/> <xsl:apply-templates/> <xsl:value-of select="$SPACE"/> <xsl:value-of select="$RBRACE"/> </xsl:template> <xsl:if test="xqx:validationMode"> <xsl:value-of select="xqx:validationMode"/> <xsl:value-of select="$SPACE"/> </xsl:if> <xsl:if test="xqx:typeName"> <xsl:text>type </xsl:text> <xsl:apply-templates select="xqx:typeName"/> <xsl:value-of select="$SPACE"/> </xsl:if> <xsl:value-of select="$LBRACE"/> <xsl:apply-templates select="xqx:argExpr"/> <xsl:value-of select="$SPACE"/> <xsl:value-of select="$RBRACE"/> <xsl:value-of select="$SPACE"/> <!-- part of higher-order functions --> <xsl:template match="xqx:dynamicFunctionInvocationExpr"> <xsl:apply-templates select="xqx:functionItem"/> <xsl:apply-templates select="xqx:predicates"/> <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>
<!-- part of higher-order functions --> <xsl:template match="xqx:functionItem"> <xsl:apply-templates/> </xsl:template> <xsl:choose> <xsl:when test="local-name(./child::*[1])='star'"> <xsl:apply-templates select="xqx:star"/> <xsl:value-of select="$COLON"/> <xsl:apply-templates select="xqx:NCName"/> </xsl:when> <xsl:when test="local-name(./child::*[1])='NCName'"> <xsl:apply-templates select="xqx:NCName"/> <xsl:value-of select="$COLON"/> <xsl:apply-templates select="xqx:star"/> </xsl:when> <xsl:when test="local-name(./child::*[1])='uri'"> <xsl:text>Q</xsl:text> <xsl:value-of select="$LBRACE"/> <xsl:value-of select="./xqx:uri"/> <xsl:value-of select="$RBRACE"/> <xsl:apply-templates select="xqx:star"/> </xsl:when> </xsl:choose> <xsl:template match="xqx:namespaceTest"> <xsl:text>namespace-node()</xsl:text> </xsl:template> <xsl:call-template name="renderEQName"/> <xsl:call-template name="renderEQName"/> <xsl:call-template name="renderEQName"/> <!-- anyFunctionTest, part of higher-order functions --> <!-- 2012-09-07: Jim added annotation support --> <xsl:template match="xqx:anyFunctionTest"> <xsl:apply-templates select="xqx:annotation"/> <xsl:text> function(*)</xsl:text> </xsl:template>
<!-- typedFunctionTest, part of higher-order functions --> <!-- 2012-09-07: Jim added annotation support --> <xsl:template match="xqx:typedFunctionTest"> <xsl:apply-templates select="xqx:annotation"/> <xsl:text> function</xsl:text> <xsl:apply-templates select="xqx:paramTypeList"/> <xsl:text> as </xsl:text> <xsl:apply-templates select="xqx:sequenceType"/> </xsl:template>
<xsl:template match="xqx:paramTypeList"> <xsl:call-template name="parenthesizedList"/> </xsl:template>
<!-- parenthesizedItemType, part of higher-order functions --> <xsl:template match="xqx:parenthesizedItemType"> <xsl:text> ( </xsl:text> <xsl:apply-templates/> <xsl:text> ) </xsl:text> </xsl:template> <xsl:if test="preceding-sibling::xqx:stepExpr"> <!-- part of higher-order functions --> <!-- Response to Bugzilla bug #12788 --> <!-- 2011-11-21 - Jim changed "literalFunctionItemExpr" to "namedFunctionRef" --> <xsl:template match="xqx:namedFunctionRef"> <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:prefix) and not(@xqx:URI)) or (@xqx:prefix and @xqx:prefix = '') or (@xqx:URI and @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:apply-templates select="xqx:functionName"/> <xsl:text>#</xsl:text> <xsl:apply-templates select="xqx:integerConstantExpr"/> </xsl:template>
<!-- part of higher-order functions --> <!-- 2011-09-09/JM - Added annotations to inline functions --> <!-- 2011-11-21 - Jim changed "inlineFunctionItemExpr" to "inlineFunctionExpr" --> <xsl:template match="xqx:inlineFunctionExpr"> <xsl:apply-templates select="xqx:annotation"/> <xsl:text> function </xsl:text> <xsl:apply-templates select="xqx:paramList"/> <xsl:apply-templates select="xqx:typeDeclaration"/> <xsl:apply-templates select="xqx:functionBody"/> </xsl:template> <xsl:template match="xqx:contentExpr"> <xsl:apply-templates/> </xsl:template> <xsl:template match="xqx:computedNamespaceConstructor"> <xsl:text> namespace </xsl:text> <xsl:choose> <xsl:when test="xqx:prefix"> <xsl:value-of select="xqx:prefix"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$LBRACE"/> <xsl:apply-templates select="xqx:prefixExpr"/> <xsl:value-of select="$RBRACE"/> </xsl:otherwise> </xsl:choose> <xsl:value-of select="$SPACE"/> <xsl:value-of select="$LBRACE"/> <xsl:apply-templates select="xqx:URIExpr"/> <xsl:value-of select="$RBRACE"/> </xsl:template> <xsl:if test="xqx:version"> <xsl:text>version </xsl:text> <xsl:call-template name="quote"> <xsl:with-param name="item" select="xqx:version"/> </xsl:call-template> </xsl:if> <xsl:if test="xqx:encoding and xqx:version"> <xsl:value-of select="$SPACE"/> </xsl:if> <xsl:if test="xqx:encoding"> <xsl:text>encoding </xsl:text> <xsl:call-template name="quote"> <xsl:with-param name="item" select="xqx:encoding"/> </xsl:call-template> </xsl:if> <xsl:template match="xqx:boundarySpaceDecl"> <xsl:text>declare boundary-space </xsl:text> <xsl:value-of select="."/> </xsl:template> <xsl:template match="xqx:decimalFormatDecl"> <xsl:text>declare </xsl:text> <xsl:if test="not(xqx:decimalFormatName)"> <xsl:text>default </xsl:text> </xsl:if> <xsl:text>decimal-format </xsl:text> <xsl:if test="xqx:decimalFormatName"> <xsl:apply-templates select="xqx:decimalFormatName"/> <xsl:text> </xsl:text> </xsl:if> <xsl:apply-templates select="xqx:decimalFormatParam"/> </xsl:template>
<xsl:template match="xqx:decimalFormatParam"> <xsl:value-of select="xqx:decimalFormatParamName"/> <xsl:text> = </xsl:text>
<xsl:call-template name="quote"> <xsl:with-param name="item" select="xqx:decimalFormatParamValue"/> </xsl:call-template>
<xsl:text> </xsl:text> </xsl:template> <!-- 2011-09-09/JM - added a sequenceTypeUnion type --> <xsl:template match="xqx:sequenceTypeUnion"> <xsl:apply-templates select="xqx:sequenceType[1]"/> <xsl:if test="count(xqx:sequenceType) > 1"> <xsl:for-each select="xqx:sequenceType[position() > 1]"> <xsl:text> | </xsl:text> <xsl:apply-templates select="."/> </xsl:for-each> </xsl:if> </xsl:template> <!-- contextItemDecl shouldn't have sequenceType, but itemType --> <xsl:template match="xqx:contextItemType"> <xsl:text> as </xsl:text> <xsl:apply-templates select="*"/> </xsl:template>
<xsl:template match="xqx:contextItemDecl"> <xsl:text>declare context item </xsl:text> <xsl:apply-templates select="xqx:typeDeclaration"/> <xsl:apply-templates select="xqx:contextItemType"/> <xsl:if test="xqx:varValue"> <xsl:value-of select="$SPACE"/> <xsl:value-of select="$ASSIGN"/> <xsl:value-of select="$SPACE"/> <xsl:apply-templates select="xqx:varValue"/> </xsl:if> <xsl:if test="xqx:external"> <xsl:text> external </xsl:text> <xsl:if test="xqx:external/xqx:varValue"> <xsl:text>:= </xsl:text> <xsl:apply-templates select="xqx:external/xqx:varValue"/> </xsl:if> </xsl:if> </xsl:template>
<xsl:template match="xqx:annotation"> <xsl:value-of select="$SPACE"/> <xsl:value-of select="$PERCENT"/> <xsl:apply-templates select="xqx:annotationName"/> <xsl:if test="xqx:arguments"> <xsl:for-each select="xqx:arguments"> <xsl:call-template name="parenthesizedList"/> </xsl:for-each> </xsl:if> </xsl:template> <xsl:text>declare</xsl:text> <xsl:apply-templates select="xqx:annotation"/> <xsl:text> variable </xsl:text> <xsl:value-of select="$DOLLAR"/> <xsl:apply-templates select="xqx:varName"/> <xsl:apply-templates select="xqx:typeDeclaration"/> <xsl:if test="xqx:varValue"> <xsl:value-of select="$ASSIGN"/> <xsl:apply-templates select="xqx:varValue"/> </xsl:if> <xsl:if test="xqx:external"> <xsl:text> external </xsl:text> <xsl:if test="xqx:external/xqx:varValue"> <xsl:text>:= </xsl:text> <xsl:apply-templates select="xqx:external/xqx:varValue"/> </xsl:if> <xsl:text>declare</xsl:text> <xsl:apply-templates select="xqx:annotation"/> <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:choose> <xsl:when test="xqx:versionDecl/xqx:encoding"> <xsl:variable name="enc"> <xsl:value-of select='xqx:versionDecl/xqx:encoding'/> </xsl:variable> <xsl:result-document encoding="{$enc}"> <xsl:apply-templates select="*"/> <xsl:fallback> <xsl:apply-templates select="*"/> </xsl:fallback> </xsl:result-document> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="*"/> </xsl:otherwise> </xsl:choose> application/xquery+xml This Appendix specifies the media type for XQueryX Version 3.0. XQueryX is the XML syntax of a language, XQuery, for querying over data from XML data sources, as specified in [XQuery 3.0: An XML Query Language] Note: Specification of media types is described in [RFC 3023] This document, together with its normative references, defines the XML syntax for the XML Query language XQuery Version 3.0. This Appendix specifies the application/xquery+xml This media type is being submitted to the IESG for review, approval, and registration with IANA. This document was prepared by members of the W3C XML Query Working Group. Please send comments to [email protected], a public mailing list with archives at http://lists.w3.org/Archives/Public/public-qt-comments application/xquery+xml MIME media type name: application MIME subtype name: xquery+xml Required parameters: none Optional parameters: charset This parameter has identical semantics to the charset application/xml By virtue of XSLT content being XML, it has the same considerations when sent as " application/xquery+xml Queries written in XQuery may cause arbitrary URIs or IRIs to be dereferenced. Therefore, the security issues of [RFC3987] Section 8 should be considered. In addition, the contents of resources identified by file: file-exists() doc() XQuery is a full declarative programming language, and supports user-defined functions, external function libraries (modules) referenced by URI, and system-specific "native" functions. Arbitrary recursion is possible, as is arbitrarily large memory usage, and implementations may place limits on CPU and memory usage, as well as restricting access to system-defined functions. The XML Query Working group is working on a facility to allow XQuery expressions to be used to create and update persistent data. Untrusted queries should not be given write access to data. Furthermore, because the XQuery language permits extensions, it is possible that application/xquery may describe content that has security implications beyond those described here. See Section 5 Conformance XQ30 This media type registration is for XQueryX documents as described by the XQueryX 3.0 specification, which is located at http://www.w3.org/TR/xqueryx-30/ The public XQuery Web page This new media type is being registered to allow for deployment of XQueryX on the World Wide Web. There is no experimental, vendor specific, or personal tree predecessor to "application/xquery+xml", reflecting the fact that no applications currently recognize it. This new type is being registered in order to allow for the expected deployment of XQueryX 3.0 on the World Wide Web, as a first class XML application. Although no byte sequences can be counted on to consistently identify XQueryX, XQueryX documents will have the sequence "http://www.w3.org/2005/XQueryX" to identify the XQueryX namespace. This sequence will normally be found in a namespace attribute of the first element in the document. The most common file extension in use for XQueryX is .xqx The appropriate Macintosh file type code is TEXT Jim Melton, Oracle Corp., [email protected] COMMON The intended usage of this media type is for interchange of XQueryX expressions. XQuery was produced by, and is maintained by, the World Wide Web Consortium's XML Query Working Group. The W3C has change control over this specification. For documents labeled as " application/xquery+xml application/xml This appendix lists the changes that have been made to this specification since the publication of the XQueryX 1.0 Recommendation on 23 January 2007. In the Recommendation of 08 April 2014, the following substantive changes have been made relative to XQueryX 1.0. The changes made to this document are described below. The rationale for each change is explained in the corresponding Bugzilla database entry (if any). The following table summarizes the changes that have been applied. Change Bugzilla Category Description Group By clause in FLWOR expression. None. Substantive. A new clause was added to the FLWOR expression to allow query writers to cause groups of tuples to be created based on the values of some expression. Window clause in FLWOR expression. None. Substantive. A new clause was added to the FLWOR expression to allow query writers to create sliding and tumbling windows of tuples based on a number of criteria. Simplification of FLWOR expression. None. Substantive. The syntax of the FLWOR expression was considerably relaxed, permitting most clauses (other than the return clause) to be used at almost any position (only a few clauses are allowed to be the first clause) within a FLWOR expression. Outer for supported in FLWOR expressions. None. Substantive. The syntax of the for clause in FLWOR expressions was extended to allow the use of "outer for". Count clause in FLWOR expression. None. Substantive. A new clause was added to the FLWOR expression to allow query writers to capture the total number of items that are returned by a (portion of a) FLWOR expression. Declaration of decimal number formats. None. Substantive. A new option was added to the query prologue, allowing query authors to specify a named (or an unnamed default) format for decimal numbers. This allows the specification of such items as the decimal separator, the minus sign, the percent and per mille signs, and even the class of Unicode digits. Query version and encoding declaration. None. Substantive. Allows specification of either or both of the version of XQuery to which a query adheres and the encoding of the query (e.g., UTF8, ISO8859-1). Enhanced validation expression. [XQuery 1.1] Requirement: validation by type Substantive. Permits query authors to validate an expression against a specified XML Schema type. Nondeterministic external functions. None. Substantive. Functions declared to be external functions can also be specified to be deterministic or nondeterministic. Syntax used to provide default value for external variables. None. Minor. The declaration of external variables now uses ":=" to indicate the default value given to such variables, instead of the keyword "default". Try/catch for error handling. None. Substantive. A try/catch facility is provided that allows query authors to control how errors are handled when raised by evaluation of queries. Context item declaration. None. Substantive. It is now possible to declare both the type of and the default initial value of the context item of a query, and to specify whether its value may be provided by the external environment. Computed namespace constructor. None. Substantive. Added new complex type and element to XQueryX schema, and new template to XQueryX stylesheet, in support of computed namespace constructors in XQuery 1.1. Generate proper syntax for variable names in positional variable bindings. [XQX30] template for positionalVariableBinding Substantive. Modified XQueryX stylesheet template to correctly generate a "$" preceding the variable name. Allow positional variable bindings to be optional in window variables. [XQX30] positionalVariableBinding should be optional in windowVars Substantive. Modified XQueryX schema to add minOccurs="0" on element positionalVariableBinding in windowVars complex type definition. XQueryX syntax must allow wildcards in the try/catch error list. [XQX30] cannot represent a catchErrorList wildcard in XQueryX Substantive. In XQueryX schema, modified catchErrorList complex type definition to allow a choice between a nameText (essentially a QName) and a Wildcard. In XQueryX stylesheet, modified catchErrorList template to support Wildcard as well as nameText. Private functions. None. Substantive. In XQueryX schema, added new attribute "private" in functionDecl complex type. In XQUeryX stylesheet, template for functionDecl, added support for @private (generate "private" for private functions and "public" for others) Replace "outer for" with "allowing empty". None. Substantive. In XQueryX schema, forClause complex type, delete attribute "outer"; in forClauseItem complex type, add new element allowingEmpty. In XQueryX stylesheet template for forClause, remove generation of "outer"; in template for forClauseItem, generate "allowing empty". Higher-order functions. None. Substantive. Made changes to XQueryX schema and stylesheet corresponding to new higher-order function syntax in XQuery 1.1. New "switch" expression ("value switch", analogous to typeswitch). None. Substantive. Made changes to XQueryX schema and stylesheet corresponding to new switch syntax in XQuery 3.0. Support for partial function application. None. Substantive. Made changes to XQueryX schema and stylesheet to support the partial function application capability of XQuery 3.0. XML Schema and XSLT Stylesheet lack of syntactic symmetry between the control flow expressions Substantive. Eliminated the possibility of defining three "error variables" as part of the catch clause; those variables (and others) are now implicitly defined, and may be used without explicit definition. At the same time, fixed a bug in the schema and stylesheet that recognized and produced invalid syntax for the validation expression. XML Schema and XSLT Stylesheet None. Substantive. Added support for the string concatenation operator ("||"). XML Schema and XSLT Stylesheet None. Substantive. Added support for the simple mapping operator ("!"). XML Schema and XSLT Stylesheet None. Substantive. Added support for the sequenceTypeUnion in the typeswitch expression. XML Schema and XSLT Stylesheet None. Substantive. Added support for the annotations on inline functions. XML Schema and XSLT Stylesheet None. Substantive. Added support for new group-by syntax. XML Schema and XSLT Stylesheet None. Substantive. Replaced the element named "literalFunctionItemExpr" with an identical element named "namedFunctionRef"; Replaced the element named "inlineFunctionItemExpr" with an identical element named "inlineFunctionExpr" XML Schema and XSLT Stylesheet Precedence of the Simple Map Operator Substantive Removed the element mapStepExpr and added an element simpleMapExpr, thus changing the precedence of the simple map operator (!). XSLT Stylesheet missing parens for try/catch expression Substantive Generate parentheses that surround the XQuery code generated for a tryCatchExpr. XML Schema and XSLT Stylesheet Annotation in FunctionTest in XQueryX (member-only message) Substantive Provide support for (annotation) assertions in function tests. XML Schema and XSLT Stylesheet [APPLET] encoding becomes version in version declaration Substantive Require that a <versionDecl> element contain a <version> element, an <encoding> element, or both. Use the <encoding> element to determine the actual encoding of the generated XQuery output. XML Schema and XSLT Stylesheet Annotation arguments Substantive Align with XQuery by restricting the operands of annotations to be literals, not expressions XML Schema and XSLT Stylesheet decimalFormatDecl Substantive Modify the manner in which XQueryX indicates that a declared decimal format is determined to be the default decimal format declaration. XML Schema and XSLT Stylesheet contextItemDecl Substantive Restrict the declared type of the context item to items, instead of sequence types in general XML Schema and XSLT Stylesheet functionDecl Substantive XQuery no longer has the ability to declare functions to be deterministic/non-deterministic, nor to declare them to be public/private by the use of ordinary keyword syntax (instead, annotations are used for declaring them public/private) In the Recommendation of 08 April 2014, the following substantive changes have been made relative to the preceding stage of this document, the Candidate Recommendation of 08 January 2013. The changes made to this document are described below. The rationale for each change is explained in the corresponding Bugzilla database entry (if any). The following table summarizes the changes that have been applied. Change Bugzilla Category Description XML Schema and XSLT Stylesheet [ 1 [XQX30] simpleMapExpr Substantive The schema definition of simpleMapExpr has been extended to permit a string of simpleMapExprs that cascade on one another. Although this was possible with the previous definition of simpleMapExpr, the XQueryX syntax to do so was lengthy, tedious, and not altogether intuitive. The stylesheet rendering of simpleMapExpr into XQuery syntax has been correspondingly modified as well. 1. The Recommendation of 08 April 2014, contains the following incompatibilities with XQueryX 1.0. The changes made to this document are described below. The rationale for each change is explained in the corresponding Bugzilla database entry (if any). The following table summarizes the changes that have been applied. Change Bugzilla Category Description (none) — — — In the Recommendation of 08 April 2014, the following editorial changes have been made relative to XQueryX 1.0. The changes made to this document are described below. The rationale for each change is explained in the corresponding Bugzilla database entry (if any). The following table summarizes the changes that have been applied. Change Bugzilla Category Description Erratum XQX.E1 Arguably incorrect element definition in XQueryX's Schema. Editorial. The published XQueryX 1.0 schema defined many elements using anonymous complex types. That made it infeasible to extend the content model of those elements in other specifications that define XQueryX extensions corresponding perhaps to XQuery extensions. While conceptually simple, a number of changes were required to ensure that all elements are defined using named complex types. Erratum XQX.E2 and Erratum XQX.E3 Removed element xqx:parenthesizedExpr used in example. Editorial. The XQueryX solution to Example 4 incorrectly contained an <xqx:parenthesizedExpr> element. That element was changed to an <xqx:sequenceExpr> element. The XSLT stylesheet in Appendix B contained a template for the transformation of <xqx:parenthesizedExpr> elements that was unnecessary and confusing; that template was deleted. Erratum XQX.E4 Bug in XQueryX applet Editorial. The XQueryX 1.0 Recommendation linked to an obsolete version of the XQuery 1.0 grammar applet. The proper link has now been used. Erratum XQX.E5 Problem with {{ and }} in a Namespace Declaration Attribute Editorial. The XSLT stylsheet in Appendix B contained a template for the transformation of <xqx:namespaceDeclaration> elements that failed to correctly "escape" curly braces in the same manner as does the template for the transformation of <xqx:attributeConstructor> elements. That template has been corrected. Introduction. [XQX] non-normative notes Editorial. Added text in 1 Introduction This appendix. None. Editorial. Reorganized this appendix to more clearly distinguish between substantive and editorial changes and to clearly identify incompatibilities with the previous Recommendation. Version number. None. Editorial. Changed the version number of the spec from 1.1 to 3.0. Introduction. section 1: schema and stylesheet URLs Editorial. Corrected the URI of the XQueryX schema document and stylesheet. Introduction. section 1: version typo Editorial. Corrected the version number of the previous version of XQueryX. Also removed normative reference to "this" document and replaced it with a reference to the XQueryX 1.0 document. XML Schema and XSLT Stylesheet (W3C confidential email) Editorial. Changed the stylesheet XSLT version number to 2.0, reflecting the new use of the xsl:result-document element to control the character encoding of the generated XQuery query.