Chapter 7. Constructing XML
In Chapter 3, you learned how to access XML that exists outside the query and navigate over it. In this chapter, you will learn how to construct XML directly in a query. Constructing XML is useful for several purposes, including creating a new result shape (transformation), representing temporary intermediate data structures (composition), and organizing data into conceptual groups (views).
XQuery has expressions for constructing all seven of the well-known XML node kinds: element, attribute, text, document, comment, processing-instruction, and namespace. For all of these node kinds, XQuery supports two different construction expressions: one with a syntax similar to XML, and an alternate XQuery syntax primarily ...