This book describes the core features of the XQuery language and its associated built-in functions and data model. There are several peripheral standards that complement, but are not central to, the XQuery language. These standards include XQuery Update Facility, XQuery and XPath Full Text (search), XQueryX, and XQJ.
The XQuery language provides expressions for querying input documents and adding to the results. However, the main XQuery specification does not have any specific expressions for inserting, updating, or deleting XML data. As we saw in “Copying Input Elements with Modifications”, it is possible to modify input elements and attributes by using user-defined functions, but this is somewhat cumbersome. In addition, this only transforms input documents to be returned as the query results; it offers no ability to specify that XML data should be permanently changed in a database.
The XQuery Update Facility is a separate W3C specification, an extension to the XQuery language, that provides specialized expressions for updates. It allows for:
Nodes can be inserted in specified positions using
insert node or
insert nodes keywords. For example, the following will insert a new product in the second position:
insert node <product><number>345</number></product> after doc("catalog.xml")//product
Nodes can be deleted using
delete node or
delete nodes keywords. For example, the following ...