Professional XML (Programmer to Programmer)

XQuery is a fairly new language for querying XML data. It was designed from the ground up by the XML Query Working Group of the W3C with the sole purpose of querying data stored in XML format. As mentioned before, it is essentially a superset of XPath 2.0 that gives it all the features of

XPath 2.0 plus a long list of additional features. The great thing about XQuery is that it was built to work with all XML documents, whether they are untyped, typed, or a combination of the two. In all cases, its job is to query data stored in XML format. It does this by using the XPath navigational functionality.

XQuery Use Cases

Application areas for XQuery can be classified broadly as follows:

Advantages of XQuery

In addition to building on top of XML querying technologies such as XPath, and XSLT, XQuery also provides a number of advantages:

Structure of an XQuery Expression

An XQuery expression consists of two sections-a prolog and a body. A prolog can in turn contain a namespace declaration subsection. Namespace declarations are used to define a mapping between prefix and namespace URI, thereby enabling you to use the prefix instead of the namespace URI in the query body. You can also refer to element names without the prefix by binding a default namespace for element names, using the declare default namespace declaration.

The body of an XQuery expression contains query expressions that define the result of the query. It can, for example, be the signature FLWOR expression (see the "FLWOR Expressions" section in this chapter), an XPath 2.0 expression, or another XQuery expression such as a construction or arithmetic expression.

Категории