O'Reilly logo

XQuery from the Experts: A Guide to the W3C XML Query Language by Philip Wadler, Jim Tivy, Jérôme Siméon, Michael Rys, Jonathan Robie, Michael Kay, Mary Fernández, Denise Draper, Don Chamberlin, Howard Katz - Editor

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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"/>
  <start_date>1999-01-05</start_date>
  <end_date>1999-01-20</end_date>
  <reserve_price>40</reserve_price>
</article>

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required