XQuery: A three-part technology
Added 26 Jul 2008
XQuery, at its simplest, is a language used to define searches of XML documents. Much
as SQL gives specific meaning to SELECT and FROM—in a particular context—XQuery defines a meaning for forward slash (/0 and at-sign
(@), as well as a host of other keywords and key-characters.
At its heart, though XQuery is made up of three components:
- The XPath specification: a means to select zero, one, or multiple nodes in an XML document
- Additional syntax to select a particular XML document, and to add selection criteria to the nodes returned from an XPath
- An API—like XQJ, the XQuery for Java API—that evaluates XQuery expressions in a specific programming language
To really master XQuery, you need a solid grasp of all three of these components. For the Java programmer, that obviously means learning XPath, learning the additional XPath syntactical constructs, and then wrapping all of this up in a Java-based API to issue XQuery expressions to an XML document.
The good news is that the XPath and XQuery syntax is fairly intuitive. If you've ever
navigated a directory structure in a UNIX® shell, a Mac OS X terminal, or a DOS
window, you're way ahead of the game. Add to that basic use of operators like less than
(<), greater than (>), and
equals (=), and you're over half of the way to being an XPath pro.