What is XQuery?

  • A W3C draft recommendation.
  • A syntax for finding and retrieving parts of XML documents.
  • An extension of the XPath language to add additional features and functions needed by a full XML query language.
  • Designed to meet the needs of the database world and the document processing world.
  • Roughly analogous to SQL but for XML instead of relational tables.

Benefits:

Application Development

  • Provides a standard syntax by which XML processors can access XML data or non-XML data exposed as virtual XML documents.
  • XQuery expressions can replace procedural code that generates new XML structures from other XML data.

Search and Retrieval

  • Enables robust queries across a large set of XML documents or virtual XML data sources.
  • Unifies interaction with XML databases and XML data sources in the same way that SQL unifies interaction with relational databases.

How XQuery Works:

From the W3C XQuery introduction page: “The mission of [XQuery] is to provide flexible query facilities to extract data from real and virtual documents on the Web, therefore finally providing the needed interaction between the web world and the database world. Ultimately, collections of XML files will be accessed like databases.”

XQuery is essentially an extension to XPath. Where XPath serves simply to address XML document components and return result sets, XQuery adds the ability to combine the result set with locally-defined elements in order to create new XML structures. XQuery includes looping and conditional constructs that XPath 1.0 does not have. XQuery also adds a large number of new functions, as well as built-in support for XML Schemas datatypes.

For example, to query a set of documents to extract their titles and return a new document, you can do something like this:

<books.i.like> { for $doc in input() return <book> $doc/title </book> } </books.i.like>

The result of this query might look like this:

<books.i.like> <book> <title>All About Otters</title> </book> </book> <title>The Little Otter That Could</title> </book> </books.i.like>

The result of one XQuery may be the input to another XQuery or to another XML process, such as an XSLT transform.

The XQuery language adds many new features and functions to Xpath 1.0, many of which will be included in XPath 2.0, which is currently under development by the W3C.

 
 

 

InfoMedia offers a wide range of XML services:

 

CSS
DOM
GROVEs
HTML
HyTime
RDF
SAX
SOAP
SGML
SVG

XLink
XML
XMLNamespace
XMLSchemas
XPath
XPointer
XQuery
XLT Formatting
XSLT
XTM

 
 
 
 

Click here to learn more about Xpath....