Skip to main content

What is XQuery?

XQuery is a functional language that is used to retrieve information stored in XML format.

What is XQuery?

XQuery is a functional language that is used to retrieve information stored in XML format.

XQuery can be used on XML documents, relational databases containing data in XML formats, or XML Databases.

The definition of XQuery as given by its W3C official documentation is as follows:

XQuery is a standardized language for combining documents, databases, Web pages and almost anything else. It is very widely implemented. It is powerful and easy to learn. XQuery is replacing proprietary middleware languages and Web Application development languages. XQuery is replacing complex Java or C++ programs with a few lines of code. XQuery is simpler to work with and easier to maintain than many other alternatives.

Features

  • Functional Language: XQuery is a language to retrieve/querying XML based data.

  • Analogous to SQL: XQuery is to XML what SQL is to databases.

  • XPath based: XQuery uses XPath expressions to navigate through XML documents.

  • Universally accepted: XQuery is supported by all major databases.

  • W3C Standard: XQuery is a W3C standard.

Advantages of XQuery

  • XQuery can be used to retrieve both hierarchical and tabular data.
  • XQuery can be used to query tree and graphical structures.
  • XQuery can be used to build and to query web pages.
  • XQuery can be used to transform XML documents into XHTML documents.
  • XQuery is ideal for XML-based databases and object-based databases. Object databases are much more flexible and powerful than purely tabular databases.

XQuery and XPath

XQuery 1.0 and XPath 2.0 share the same data model and support the same functions and operators. If you have already studied XPath, you will have no trouble understanding XQuery.

XQuery is a W3C Recommendation

XQuery is compatible with several W3C standards, such as XML, Namespaces, XSLT, XPath, and XML Schema.

XQuery 1.0 became a W3C Recommendation in 2007.