4 Tutorial: Using XQuery


W3C defines the XML Query (XQuery) language for querying XML and combining data from documents, databases, Web pages, and other sources. Some common use cases for XQuery involve XML publishing to create XML for Web messages, dynamic web sites, or publishing applications. The original data may be found in XML files, relational databases, or other combinations.

Some of the queries in this tutorial operate on XML stored in files, some on an XML view of a relational database, and some work on both. All of the examples in this tutorial have been tested with DataDirect XQuery. Because all XQuery implementations do not access relational data in the same way, this tutorial uses fn:collection(), which DataDirect XQuery uses to access relational tables.

Most XQuery functionality, such as arithmetic operators, comparisons, function calls, and functions, is familiar to most programmers. This tutorial focuses on the three major capabilities that distinguish XQuery, which are fundamental to processing and creating XML.

Together, these capabilities make it easier to process and create XML results with XQuery than with other languages when using data from XML or relational sources.