Database Reference
In-Depth Information
Inside a modifications element, you can specify the updates using certain XML ele‐
ments (all of these elements have a select attribute that must contain an XPath
expression evaluating to a node set):
insert-before , insert-after
Inserts content before or after the node(s) specified in the select attribute
append
Appends content as a child of the node(s) specified in the select attribute
update
Updates the contents of the node(s) specified in the select attribute
remove
Removes the node(s) specified in the select attribute
To specify new content, you can use a direct XML fragment as shown in Example 5-1
or use one of the following constructions (all elements in the http://
www.xmldb.org/xupdate namespace):
element name="..."
Creates an element node.
attribute name="..."
Creates an attribute node. The contents of the element will become the attribute's
value.
text
Creates a text node. The contents of the element will become the node's value
(a.k.a. the text).
The original XUpdate specification also mentions processing-
instruction , comment , and using variables with variable and
value-of . This is not supported in eXist.
Executing XUpdate
To execute an XUpdate document, eXist contains the following XQuery extension
function:
xmldb:update ( $ collection-uri as xs:string , $ modifications as node ())
as xs:integer
Here, $collection-uri is the collection the XUpdate is applied to. Notice that this is
a collection , so the XUpdate is performed against all documents in the collection (and
any subcollections, recursively). Make sure your XUpdate specification targets the
Search WWH ::




Custom Search