====== XQuery: An XML Query Language Resources & References ====== * [[http://www.w3.org/XML/Query/|XQuery Working Group (W3C)]] \\ =====Contents===== * [[https://www.linuxfoundation.org/#XQuery:_An_XML_Query_Language_Resources_.26_References|1 XQuery: An XML Query Language Resources & References]] * [[https://www.linuxfoundation.org/#XQuery_1.0:_An_XML_Query_Language|1.1 XQuery 1.0: An XML Query Language]] * [[https://www.linuxfoundation.org/#XQuery.2C_1.0:_An_XML_Query_Language|1.1.1 XQuery, 1.0: An XML Query Language]] * [[https://www.linuxfoundation.org/#XML_Syntax_for_XQuery_1.0_.28XQueryX.29|1.1.2 XML Syntax for XQuery 1.0 (XQueryX)]] * [[https://www.linuxfoundation.org/#XQuery_.26_XPath_Use_Cases_.28Full_Text.2C_version_1.0.29|1.1.3 XQuery & XPath Use Cases (Full Text, version 1.0)]] * [[https://www.linuxfoundation.org/#XQuery_1.0_and_XPath_2.0_Data_Model_.28XDM.29|1.1.4 XQuery 1.0 and XPath 2.0 Data Model (XDM)]] * [[https://www.linuxfoundation.org/#XQuery_1.0_and_XPath_2.0_Functions_and_Operators|1.1.5 XQuery 1.0 and XPath 2.0 Functions and Operators]] * [[https://www.linuxfoundation.org/#XQuery_Update_Facility.2C_1.0_.28Candidate_Recommendation.29|1.1.6 XQuery Update Facility, 1.0 (Candidate Recommendation)]] * [[https://www.linuxfoundation.org/#XQuery_1.0_and_XPath_2.0_Formal_Semantics|1.1.7 XQuery 1.0 and XPath 2.0 Formal Semantics]] * [[https://www.linuxfoundation.org/#XQuery_1.0_Scripting_Extension|1.1.8 XQuery 1.0 Scripting Extension]] * [[https://www.linuxfoundation.org/#XSLT_2.0_and_XQuery_1.0_Serialization|1.1.9 XSLT 2.0 and XQuery 1.0 Serialization]] * [[https://www.linuxfoundation.org/#XQuery_1.0_and_XPath_2.0_Functions_and_Operators_2|1.1.10 XQuery 1.0 and XPath 2.0 Functions and Operators]] * [[https://www.linuxfoundation.org/#Building_a_Tokenizer_for_XPath_or_XQuery|1.1.11 Building a Tokenizer for XPath or XQuery]] * [[https://www.linuxfoundation.org/#XQuery_1.1|1.2 XQuery 1.1]] ===== XQuery 1.0: An XML Query Language ===== [[http://www.w3.org/TR/xquery/|XQuery, 1.0: An XML Query Language]] * Abstract: > XML is a versatile markup language, capable of labeling the information content of diverse data sources including structured and semi-structured documents, relational databases, and object repositories. A query language that uses the structure of XML intelligently can express queries across all these kinds of data, whether physically stored in XML or viewed as XML via middleware. This specification describes a query language called XQuery, which is designed to be broadly applicable across many types of XML data sources. * [[http://www.w3.org/TR/xquery-use-cases/|XML Query (XQuery) Use Cases]] * [[http://www.w3.org/TR/xquery-requirements/|XML Query (XQuery) Requirements]] * [[http://www.w3.org/XML/Query/test-suite/|XQuery Test Suite]] [[http://www.w3.org/TR/xqueryx/|XML Syntax for XQuery 1.0 (XQueryX)]] * Introduction: > The [[http://www.w3.org/TR/xqueryx/#xquery-requirements|XML Query 1.0 Requirements]] states that "The XML Query Language MAY have more than one syntax binding. One query language syntax MUST be convenient for humans to read and write. One query language syntax MUST be expressed in XML in a way that reflects the underlying structure of the query."\\ \\ 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.\\ \\ 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 [[http://www.w3.org/TR/xqueryx/#xquery|XQuery 1.0: An XML Query Language]].\\ \\ There are several environments in which XQueryX may be useful: - Parser Reuse. In heterogeneous environments, a variety of systems may be used to execute a query. One parser can generate XQueryX for all of these systems. - Queries on Queries. Because XQueryX is represented in XML, queries can be queried and can be transformed into new queries. For instance, a query can be performed against a set of XQueryX queries to determine which queries use FLWOR expressions to range over a set of invoices. - Generating Queries. In some XML-oriented programming environments, it may be more convenient to build a query in its XQueryX representation than in the corresponding XQuery representation, since ordinary XML tools can be used. - Embedding Queries in XML. XQueryX can be embedded directly in an XML document.\\ \\ The most recent versions of the XQueryX XML Schema and the XQueryX XSLT stylesheet are available at [[http://www.w3.org/2005/XQueryX/xqueryx.xsd|http://www.w3.org/2005/XQueryX/xqueryx.xsd]] and [[http://www.w3.org/2005/XQueryX/xqueryx.xsl|http://www.w3.org/2005/XQueryX/xqueryx.xsl]], respectively.[[http://www.w3.org/TR/xpath-full-text-10-use-cases/|XQuery & XPath Use Cases (Full Text, version 1.0)]] * Abstract: > This document specifies usage scenarios for full-text queries as part of XML Query [[http://www.w3.org/TR/xquery/|XQuery 1.0: An XML Query Language]] and [[http://www.w3.org/TR/xpath20/|XML Path Language (XPath) 2.0]].[[http://www.w3.org/TR/xpath-datamodel/|XQuery 1.0 and XPath 2.0 Data Model (XDM)]] * Abstract: > This document defines the W3C XQuery 1.0 and XPath 2.0 Data Model (XDM), which is the data model of [[http://www.w3.org/TR/xpath20/|XPath 2.0]], [[http://www.w3.org/TR/xslt20/|XSLT 2.0]], and [[http://www.w3.org/TR/xquery/|XQuery]], and any other specifications that reference it. This data model is based on the [[http://www.w3.org/TR/xpath|XPath 1.0]] data model and earlier work on an [[http://www.w3.org/TR/2001/WD-query-datamodel-20010215/|XML Query Data Model]]. This document is the result of joint work by the [[http://www.w3.org/Style/XSL/|XSL Working Group]] and the [[http://www.w3.org/XML/Query|XML Query Working Group]].[[http://www.w3.org/TR/xpath-functions/|XQuery 1.0 and XPath 2.0 Functions and Operators]] * Abstract: > This document defines constructor functions, operators and functions on the datatypes defined in [[http://www.w3.org/TR/xmlschema-2/|XML Schema Part 2: Datatypes Second Edition]] and the datatypes defined in [[http://www.w3.org/TR/query-datamodel/|XQuery 1.0 and XPath 2.0 Data Model]]. It also discusses functions and operators on nodes and node sequences as defined in the [[http://www.w3.org/TR/query-datamodel/|XQuery 1.0 and XPath 2.0 Data Model]]. These functions and operators are defined for use in [[http://www.w3.org/TR/xpath20/|XML Path Language (XPath) 2.0]], [[http://www.w3.org/TR/xquery/|XQuery 1.0: An XML Query Language]] and [[http://www.w3.org/TR/xslt20/|XSL Transformations (XSLT) Version 2.0]] and other related XML standards. The signatures and summaries of functions defined in this document are available at: [[http://www.w3.org/2005/xpath-functions|http://www.w3.org/2005/xpath-functions]]. * [[http://www.w3.org/TR/2004/WD-xquery-full-text-20040709/|XQuery 1.0 and XPath 2.0 Full Text]] [[http://www.w3.org/TR/2008/CR-xquery-update-10-20080801/|XQuery Update Facility, 1.0 (Candidate Recommendation)]] * Introduction: > This document defines the syntax and semantics of an extension to [[http://www.w3.org/TR/xquery/|XQuery 1.0]] called the XQuery Update Facility 1.0. This language extension is designed to meet the requirements for updating instances of the [[http://www.w3.org/TR/xpath-datamodel/|XQuery/XPath Data Model (XDM)]], as defined in [[http://www.w3.org/TR/xquery-update-10-requirements/|XQuery Update Facility Requirements]].The XQuery Update Facility 1.0 provides facilities to perform any or all of the following operations on an XDM instance: * Insertion of a node. * Deletion of a node. * Modification of a node by changing some of its properties while preserving its node identity. * Creation of a modified copy of a node with a new node identity.Additionally, this document defines an XML syntax for the XQuery Update Facility 1.0. The most recent versions of the two XQueryX XML Schemas and the XQueryX XSLT stylesheet for the XQuery Update Facility 1.0 are available at [[http://www.w3.org/2007/xquery-update-10/xquery-update-10-xqueryx.xsd|http://www.w3.org/2007/xquery-update-10/xquery-update-10-xqueryx.xsd]], [[http://www.w3.org/2007/xquery-update-10/xquery-update-10-xqueryx-redef.xsd|http://www.w3.org/2007/xquery-update-10/xquery-update-10-xqueryx-redef.xsd]], and [[http://www.w3.org/2007/xquery-update-10/xquery-update-10-xqueryx.xsl|http://www.w3.org/2007/xquery-update-10/xquery-update-10-xqueryx.xsl]], respectively. * [[http://www.w3.org/TR/xquery-update-10-requirements/|XQuery Update Requirements]] [[http://www.w3.org/TR/xquery-semantics/|XQuery 1.0 and XPath 2.0 Formal Semantics]] * Introduction: > This document defines the formal semantics of XQuery 1.0 and XPath 2.0. The present document is part of a set of documents that together define the XQuery 1.0 and XPath 2.0 languages: * [[http://www.w3.org/TR/xquery/|XQuery 1.0: An XML Query Language]] introduces the XQuery 1.0 language, defines its capabilities from a user-centric view, and defines the language syntax. * [[http://www.w3.org/TR/xpath20/|XML Path Language (XPath) 2.0]] introduces the XPath 2.0 language, defines its capabilities from a user-centric view, and defines the language syntax. * [[http://www.w3.org/TR/xpath-functions/|Functions and Operators]] lists the functions and operators defined for the **XPath/XQuery** language and specifies the required types of their parameters and return value. * [[http://www.w3.org/TR/xpath-datamodel/|Data Model]] formally specifies the data model used by **XPath/XQuery** to represent the content of XML documents. The **XPath/XQuery** language is formally defined by operations on this data model. * [[http://www.w3.org/TR/xslt-xquery-serialization/|Data Model Serialization]] specifies how **XPath/XQuery** data model values are serialized into XML.The scope and goals for the **XPath/XQuery** language are discussed in the charter of the W3C XSL/XML Query Working Group and in the **XPath/XQuery** requirements [[http://www.w3.org/TR/xquery-requirements|XML Query 1.0 Requirements]].\\ \\ This document defines the semantics of **XPath/XQuery** by giving a precise formal meaning to each of the expressions of the **XPath/XQuery** specification in terms of the **XPath/XQuery** data model. This document assumes that the reader is already familiar with the **XPath/XQuery** language. This document defines the formal semantics for XPath 2.0 only when the XPath 1.0 backward compatibility rules are not in effect.\\ \\ Two important design aspects of **XPath/XQuery** are that it is functional and that it is typed. These two aspects play an important role in the **XPath/XQuery** Formal Semantics.\\ \\ **XPath/XQuery** is a functional language. **XPath/XQuery** is built from expressions, rather than statements. Every construct in the language (except for the XQuery query prolog) is an expression and expressions can be composed arbitrarily. The result of one expression can be used as the input to any other expression, as long as the type of the result of the former expression is compatible with the input type of the latter expression with which it is composed. Another characteristic of a functional language is that variables are always passed by value, and a variable's value cannot be modified through side effects.\\ \\ **XPath/XQuery** is a typed language. Types can be imported from one or more XML Schemas that describe the input documents and the output document, and the **XPath/XQuery** language can then perform operations based on these types. In addition, **XPath/XQuery** supports static type analysis. Static type analysis infers the output type of an expression based on the type of its input expressions. In addition to inferring the type of an expression for the user, static typing allows early detection of type errors, and can be used as the basis for certain classes of optimization. The **XPath/XQuery** type system captures most of the features of [[http://www.w3.org/TR/xmlschema-1/|Schema Part 1]], including global and local element and attribute declarations, complex and simple type definitions, named and anonymous types, derivation by restriction, extension, list and union, substitution groups, and wildcard types. It does not model uniqueness constraints and facet constraints on simple types.\\ \\ This document is organized as follows. [[http://www.w3.org/TR/xquery-semantics/#sec_preliminaries|2 Preliminaries]] introduces the notations used to define the **XPath/XQuery** Formal Semantics. These include the formal notations for values in the **XPath/XQuery** data model and for types in XML Schema. The next three sections: [[http://www.w3.org/TR/xquery-semantics/#id-basics|3 Basics]], [[http://www.w3.org/TR/xquery-semantics/#id-expressions|4 Expressions]], and [[http://www.w3.org/TR/xquery-semantics/#id-query-prolog|5 Modules and Prologs]] have the same structure as the corresponding sections in the [[http://www.w3.org/TR/xquery/|XQuery 1.0: An XML Query Language]] and [[http://www.w3.org/TR/xpath20/|XML Path Language (XPath) 2.0]] documents. This allows the reader to quickly find the formal definition of a particular language construct. [[http://www.w3.org/TR/xquery-semantics/#id-basics|3 Basics]] defines the semantics for basic **XPath/XQuery** concepts, and [[http://www.w3.org/TR/xquery-semantics/#id-expressions|4 Expressions]] defines the dynamic and static semantics of each **XPath/XQuery** expression. [[http://www.w3.org/TR/xquery-semantics/#id-query-prolog|5 Modules and Prologs]] defines the semantics of the **XPath/XQuery** prolog. [[http://www.w3.org/TR/xquery-semantics/#sec_special_functions|7 Additional Semantics of Functions]] defines the static semantics of several functions in [[http://www.w3.org/TR/xpath-functions/|Functions and Operators]] and gives the dynamic and static semantics of several supporting functions used in this document. The remaining sections, [[http://www.w3.org/TR/xquery-semantics/#sec_auxiliary_judgments|8 Auxiliary Judgments]] and [[http://www.w3.org/TR/xquery-semantics/#sec_importing_schema|D Importing Schemas]], contain material that supports the formal semantics of **XPath/XQuery**. [[http://www.w3.org/TR/xquery-semantics/#sec_auxiliary_judgments|8 Auxiliary Judgments]] defines formal judgments that relate data model values to types, that relate types to types, and that support the formal definition of validation. These judgments are used in the definition of expressions in [[http://www.w3.org/TR/xquery-semantics/#id-expressions|4 Expressions]]. Lastly, [[http://www.w3.org/TR/xquery-semantics/#sec_importing_schema|D Importing Schemas]], specifies how XML Schema documents are imported into the **XPath/XQuery** type system and relates XML Schema types to the **XPath/XQuery** type system.[[http://www.w3.org/TR/xquery-sx-10/|XQuery 1.0 Scripting Extension]] * Abstract: > This specification defines an extension to [[http://www.w3.org/TR/xquery/|XQuery 1.0]] and [[http://www.w3.org/TR/xquery-update-10/|XQuery Update Facility]]. Expressions can be evaluated in a specific order, with later expressions seeing the effects of the expressions that came before them. This specification introduces the concept of a block with local variable declarations, as well as several new kinds of expressions, including assignment, while, continue, break, and exit expressions. * [[http://www.w3.org/TR/xquery-sx-10-requirements/|XQuery 1.0 Scripting Extension 1.0 Requirements]] [[http://www.w3.org/TR/xslt-xquery-serialization/|XSLT 2.0 and XQuery 1.0 Serialization]] * Introduction: > This document defines serialization of the W3C XQuery 1.0 and XPath 2.0 Data Model (XDM), which is the data model of at least [[http://www.w3.org/TR/xpath20/|XML Path Language (XPath) 2.0]], [[http://www.w3.org/TR/xslt20/|XSL Transformations (XSLT) Version 2.0]], and [[http://www.w3.org/TR/xquery/|XQuery 1.0: An XML Query Language]], and any other specifications that reference it.\\ \\ Serialization is the process of converting an instance of the [[http://www.w3.org/TR/xpath-datamodel/|XQuery 1.0 and XPath 2.0 Data Model]] into a sequence of octets. Serialization is well-defined for most data model instances.[[http://www.w3.org/TR/2003/WD-xpath-functions-20030502/|XQuery 1.0 and XPath 2.0 Functions and Operators]] * Introduction: > [[http://www.w3.org/TR/xmlschema-2/|XML Schema Part 2: Datatypes]] defines a number of primitive and derived datatypes, collectively known as built-in datatypes. This document defines operations on these datatypes as well as the two datatypes defined in [[http://www.w3.org/TR/2003/WD-xpath-functions-20030502/#new-datatypes|1.3 xdt:anyAtomicType and xdt:untypedAtomic]] and the two totally ordered subtypes of ''xs:duration'' defined in [[http://www.w3.org/TR/2003/WD-xpath-functions-20030502/#duration-subtypes|9.2 Two Totally Ordered Subtypes of Duration]], for use in XQuery, XPath, XSLT and related XML standards. This document also discusses operators and functions on nodes and node sequences as defined in the [[http://www.w3.org/TR/query-datamodel/|XQuery 1.0 and XPath 2.0 Data Model]] for use in XQuery, XPath, XSLT and other related XML standards. * [[http://www.w3.org/2005/qt-applets/xqueryApplet.html|XQuery 1.0 Grammar Test Page]] [[http://www.w3.org/TR/xquery-xpath-parsing/|Building a Tokenizer for XPath or XQuery]] * Abstract: > This document describes possible strategies for tokenizing the [[http://www.w3.org/TR/xpath20|XML Path Language (XPath) 2.0]] and [[http://www.w3.org/TR/xquery|XQuery 1.0: An XML Query Language]] languages, and is provided as a helpful guide to those who are designing an implementation for these languages, and as background material for the normative EBNF found in the language specifications. In the future this document may be expanded to cover more general parsing strategies. \\ ---- ===== XQuery 1.1 ===== * [[http://www.w3.org/TR/xquery-11-requirements/|XQuery 1.1 Requirements (23 January 2007)]] * [[http://www.w3.org/TR/xquery-11-use-cases/|XQuery 1.1 Use Cases]]