Chapter 28. Additional XQuery-Related Standards
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.
XQuery Update Facility
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:
- Inserting nodes
Nodes can be inserted in specified positions using
insert node
orinsert 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[1]
- Deleting nodes
Nodes can be deleted using
delete node
ordelete nodes
keywords. For example, the following ...
Get XQuery, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.