XQUERY: A GUIDED TOUR
*Note: This book excerpt is from XQuery from the Experts: A Guide to the W3C XML Query Language by Howard Katz, Don Chamberlin, Denise Draper, Mary Fernandez, Michael Kay, Jonathan Robie, Michael Rys, Jerome Simeon, Jim Tivy, and Philip Wadler, (ISBN 0-321-18060-7), copyright 2004. All rights reserved. Material posted with permission from Addison-Wesley.
Table of Contents:
A Brief Introduction to XQuery
XML (Extensible Markup Language) is an extremely versatile data format that has been used to represent many different kinds of data.
Getting Started with XQuery - Sample Data: A Bibliography
This chapter uses bibliography data to illustrate the basic features of XQuery.
The XQuery Data Model
XQuery is defined in terms of a formal data model, not in terms of XML text.
Literals and Comments in XQuery
XQuery uses "smiley faces" to begin and end comments. This cheerful notation was originally suggested by Jeni Tennison.
Input Functions in XQuery
XQuery uses input functions to identify the data to be queried.
Locating Nodes with Path Expressions in XQuery
In XQuery, path expressions are used to locate nodes in XML data. XQuery's path expressions are derived from XPath 1.0 and are identical to the path expressions of XPath 2.0.
Creating Nodes with Elements, Attribute and Document Constructors in XQuery
Now we will learn how to create nodes. Elements, attributes, text nodes, processing instructions, and comments can all be created using the same syntax as XML.
Combining and Restructuring Nodes in XQuery
Queries in XQuery often combine information from one or more sources and restructure it to create a new result. This section focuses on the expressions and functions most commonly used for combining and restructuring XML data.
XQuery Operators
Like most languages, XQuery has arithmetic operators and comparison operators, and because sequences of nodes are a fundamental datatype in XQuery, it is not surprising that XQuery also has node sequence operators.
XQuery Built-in Functions
XQuery has a set of built-in functions and operators, including many that are familiar from other languages, and some that are used for customized XML processing.
User-Defined Functions in XQuery
When a query becomes large and complex, it is often much easier to understand if it is divided into functions, and these functions can be reused in other parts of the query.
Variable Definitions in XQuery
A query can define a variable in the prolog. Such a variable is available at any point after it is declared.
Library Modules in XQuery
Functions can be put in library modules, which can be imported by any query. Every module in XQuery is either a main module, which contains a query body to be evaluated, or a library module, which has a module declaration but no query body.
External Functions and Variables in XQuery
XQuery implementations are often embedded in an environment such as a Java or C# program or a relational database. The environment can provide external functions and variables to XQuery.
Types in XQuery
XML documents contain a wide range of type information, from very loosely typed information without even a DTD, to rigidly structured data corresponding to relational data or objects.
XQuery in a Nutshell
XQuery is not only a query language, but also a language that can do fairly general processing of XML. It is a strongly typed language that works well with data that may be strongly or weakly typed.




