Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

Web Development

XQuery: The Technology and the Book


Cameron is vice president of Phaseit, a consultancy specializing in high-reliability and high-performance applications managed by high-level languages.


XQuery
Priscilla Walmsley
O'Reilly, 2007
510 pp., $49.99
ISBN: 0-596-00634-9

I think XQuery is an important book. I'm not wise enough to be sure, though. I'll explain XQuery as a technology and book; you decide for yourself how much applies to you.

You have an XML document (or two, or a few million). You want to retrieve specific information from it (them). How do you do that?

Early in the history of XML, it took programming -- serious programming -- to get anything useful from a document. Initialisms like SAX and DOM represent the best of these approaches. With enough effort, such interfaces made it possible to program XML editors, report-writers, and so on.

Compare to SQL

The relational database world seems to have it better. There, SQL is a single standard that supports many implementations, at least has the reputation of being learnable by non-programmers, and certainly supports interesting optimizations. Wouldn't the XML world make more sense with a "query language" analogous to SQL?

Probably so. Confusingly enough, there are at least three special-purpose languages focused on XML that might fit this description:

  • XPath is an "expression language" (as "regular expressions" are). XPath can address the most important elements of XML elements and compute simple results based on them. XPath is easy to learn, and, like REs, is probably most used as an addressing technique embedded in a larger language, like XSLT, DOM, or XQuery.
  • XSLT is a functional language that operates on the universe of XML instances, transforming them into other XML documents or occasionally more general reports. XSLT is large, verbose, and relatively mature.
  • XQuery is a query language similar in many ways to SQL. It's younger than XSLT and has simpler syntax and semantics, although it is also functional and typed, in a slightly different way. Moreover, XQuery operates on collections of XML documents, not just single instances.

There are a few other languages, like XPointer and SQL/XML, whose use is related to XPath, XSLT, and XQuery, but we'll concentrate on the "big three".

XQuery is a marvelous book. Walmsley is as deeply involved in XML standardization and coding as anyone; at the same time, she writes clearly and sensibly. The combination is rare. While I'm a generally a fussy reviewer who frowns over even such small matters as punctuation, I've found nothing stylistic in XQuery I'd change -- not the sequence of topics, not the way the book transitions from tutorial to reference material, and not the apt selection of examples.

Any developer working with XML can read XQuery. It concisely introduces pertinent independent topics, including XPath, REs, namespaces, XML Schema, URIs, and other names, and query design. I particularly appreciate such "cultural" material as comparisons with SQL and XSLT and the paradigms of push and pull processing. I expect to keep XQuery on my bookshelf for years to come.

Less certain to me, though, is how it will serve others. The difficulty is that XQuery is in the middle of great change. As mentioned above, it's much younger than XSLT, at least in the wide availability of conforming processors. XQuery Update, XQuery 1.1, XQuery Scripting, and XQuery Full-Text are significant enhancements and extensions to XQuery that promise to expand the language's power a great deal.

Conclusion?

I don't understand XML well enough to know what the outcome will be. As things stand now, serious XML processing is typically done in a rather volatile medley of XSLT, XPath, host-language libraries like JAXP and XQJ, and external scripting. When will the important XQuery extensions begin to appear in production systems? Will their availability significantly reduce the importance of XSLT, or change the uses of XQuery 1.0? It seems possible to me our use of XQuery might be much different in a year than it is now; I simply can't predict how good a guide XQuery will be at that time to XQuery best practices.

For now, though, this book is the best and most current single introduction and reference to XQuery 1.0 as we know it in 2007. I'm wary about reliance on XQuery to make technology decisions; if you've already chosen XQuery as an expressive form, though, be sure you have XQuery so you can make the best of it.


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.