Manage Learn to apply best practices and optimize your operations.

XQuery 1.0: A long time coming, now what?

While the XQuery 1.0 specification may have taken years to get finalized, major database engines already support it. XML guru Ed Tittel notes that there's a massive reservoir of available information on XQuery as well, making it a standard that's immediately ready to move into production.

When the XQuery 1.0 Recommendation was finally approved on January 23, 2007, it marked the culmination of a long-term series of efforts that got underway at around the same time as XSLT and XPath (though both of those recommendations achieved 2.0 status on the same date as XQuery 1.0). A popular analogy for explaining XQuery is to liken it to the Structured Query Language (SQL) widely used for accessing databases of all kinds, by saying that "XQuery is to XML documents as SQL is to compatible databases."

But the analogy goes further. In fact, XQuery shares many semantic features with SQL, so that just as SQL provides database users with the tools they need to request, extract and format data results from databases by means of structured queries, so also does XQuery do likewise for users who seek access to contents and data within XML documents.

This proclamation from the XML Query project makes this crystal clear: "The mission of the XML Query project is to provide flexible query facilities to extract data from real and virtual documents on the World Wide 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" (citation from a mailing list posting from Jonathan Robie, an editor of the XQuery 1.0 Recommendation, to Tim Bray and Michael Champion dated 10/25/2003).

In this connection, it's also worth observing that most major database engines, including IBM DB/2, Microsoft SQL Server, Oracle, MySQL and many others, already support XQuery and are thus just raring to go work against XML document sets.

Basic knowledge ingredients needed to work with XQuery include a working knowledge of basic markup languages (XML and HTML will do nicely), XML namespaces and how they operate, and XPath, which works in tandem with XQuery to target specific document collections for interrogation. In fact, those already familiar with XPath will understand XQuery best as a set of specially-formatted XPath expressions specifically aimed at locating and extracting elements and attributes from XML documents (or collections of such documents). Of course, some familiarity with SQL won't hurt either, so XQuery is as likely to draw-in database and application developers, as it is to extend the reach of XML pros.

If you want to start digging into XQuery and mastering this query language, here are several great places to get started:

  • W3Schools offers a terrific and fairly detailed XQuery Tutorial that's chock-full of examples, syntax illustrations, features and functions.
  • A set of XQuery function examples from Priscilla Walmsley, taken from her recently released (April, 2007) O'Reilly book entitled XQuery (O'Reilly Media, Apri1 1, 2007, ISBN: 0596006349).
  • A set of tutorial materials developed in 2003 by Anders Møller and Michael I. Schwartzbach for their book An Introduction to XML and Web Technologies (Addison-Wesley, January 2006, ISBN: 032169667).

For a lengthy list of related publications, tutorials and example sets see the links at the end of the W3C's XML Query page. There's more material than you can shake a stick at and plenty to help just about anybody get into this fascinating subject matter.

About the author

Ed Tittel is a full-time writer and trainer whose interests include XML and development topics, along with IT Certification and information security topics. Among his many XML projects are XML For Dummies, 4th edition, (Wylie, 2005) and the Shaum's Easy Outline of XML (McGraw-Hill, 2004). E-mail Ed at with comments, questions or suggested topics or tools for review.

Dig Deeper on Topics Archive

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.