Introduction
This tutorial is designed to assist XQuery users who would like to better understand its capabilities, particularly those pertaining to data transformation, as well as Resource Description Framework (RDF) users who want to use XQuery to move existing XML data into RDF. The tutorial demonstrates how to use XQuery to transform a specific XML vocabulary into RDF.
This tutorial assumes you are familiar with the basics of XML. You do not need in depth knowledge of either XQuery or RDF to use the XQuery code developed here; however, the more you know about either subject, the more you're likely to appreciate what's going on. Although Basic principles provides some information on RDF issues, the main focus of the tutorial is XQuery.
This tutorial uses a specific XML vocabulary as a simple illustration of how to generally use XQuery to transform XML into RDF. The methodology used here is to move the XML data into a particular application of XML known as RDF/XML, the official transfer syntax, or serialization format, for RDF (according to the W3C, the organization responsible for the RDF specification). The source XML vocabulary in the tutorial is the bib.xml sample bibliography that's part of the Use Cases document that ships with the XQuery specification (see Resources for more information).
In discussing how to use XQuery to make this transformation, the tutorial looks at a number of XQuery's syntactic features. These are stock-standard XQuery mechanisms that are useful for working with XML transformations in general, not just in the present application. The mechanisms I'll show you include:
- Constructing elements (both directly and computationally)
- Accessing element text content
- Accessing attribute text content
- Using
FLWORexpressions to iterate through node sequences - Using the built-in
doc()function to access XML tree content - Using user-defined functions
- Using well-known and explicitly-declared namespaces


