Element Construction

We've seen how to perform operations on data, use path expressions to select data, and iterate over data. Now we look at how to construct data. The simplest way to construct data is to include literal XML data in a query. Here is an example:

<article id="1001">
  <name>Red Bicycle</name>
  <seller idref="U01"/>

has type element(article).

The type of this expression is the type declared for the article element in Listing 4.2. This type states that the element has one attribute (an id of type xs:ID), and five elements (including start_date and end_date, both of type xs:date). At evaluation time, the element is constructed ...

Get XQuery from the Experts: A Guide to the W3C XML Query Language now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.