XQuery is a functional language designed to query and manipulate XML data. It is a superset of XPath, to which it adds features such as the creation of new nodes and more powerful FLWOR expressions. Although it shares its data model with XSLT, XQuery is optimized for querying rather than transforming data, and as such it has a different design inspired by SQL.
W3C XML Query
XQuery has a rich set of features that allow many different types of operations on xml data and documents, including:
- Selecting information based on specific criteria
- Filtering out unwanted information
- Updates
- Searching for information within a document or set of documents
- Joining data from multiple documents or collections of documents
- Sorting, grouping, and aggregating data
- Transforming and restructuring XML data into another XML vocabulary
or structure - Performing arithmetic calculations on numbers and dates
- Manipulating strings to reformat text
XQuery can be used not just to extract sections of XML documents, but also to manipulate and transform the results.
Modified from O'Reilly XQUERY ISBN-10: 0-596-00634-9 By Priscilla Walmsley.
Relationship to XSLT
XQuery has a large overlap with xslt in terms of purpose but has a syntax and model inspired largely by sql. Most built in functions are shared with XSLT.
Relationship to XPath
XQuery is mostly a superset of xpath. XQuery version 1 is based on XPath version 2. XQuery version 3 is based on XPath version 3. Version 2 was skipped in order to align the XQuery and XPath version numbers. XQuery 3.1 like XPath 3.1 supports JSON processing through the new map and array types and JSON <--> XML conversion using the xml-to-json
and json-to-xml
functions as well as parse-json
and json-doc
functions.
Implementations
- A list of the current implementations according to the W3C XML Query group.
- Version 9.8 and later of the Saxon processor support both XSLT 3.0 and XQuery 3.1.
- BaseX implements all versions of the language and can be use through a CLI.
References
- Wikipedia
- W3C recommendations: