Database Reference
In-Depth Information
Note that you cannot replace document root nodes using update replace . Only
nodes with a parent element node can be replaced.
update value
update value updates the content of nodes. Its syntax is:
update value expr1 with expr2
Its functionality is equivalent to update replace , but it updates only values, not
nodes.
XUpdate
XUpdate is an older mechanism to change the contents of the database in an indirect
way. You first specify the required changes in an XML document using the XUpdate
syntax. You then pass this document to an XUpdate processor that applies them. The
full XUpdate specification can be found at http://xmldb-org.sourceforge.net/xupdate/
xupdate-wd.html . Using the XUpdate mechanism is mostly discouraged, but it's still
there for backward compatibility.
In Example 5-1 , the XUpdate document inserts a log message in a logfile, before any
existing ones.
Example 5-1. XUpdate document
let $ xupdate-specification :=
<xupdate:modifications version = " 1.0 " xmlns:xupdate = " http://www.xmldb.org/xupdate " >
<xupdate:insert-before select = " /Log/LogEntry[1] " >
<LogEntry> Something happened... </LogEntry>
</xupdate:insert-before>
</xupdate:modifications>
let $ update-count := xmldb:update ( '/db/logs' , $ xupdate-specification )
return
<p> The number of log entries added was { $ update-count } </p>
XUpdate XML format
An XUpdate document is an XML document that contains one or more XUpdate
XML fragments. An XUpdate XML fragment always uses the namespace http://
www.xmldb.org/ :
<modifications xmlns = "http://www.xmldb.org/xupdate"
version = "1.0">
( insert-before | insert-after | append | update | remove )*
</modifications>
• The version attribute always has the fixed value "1.0" .
Search WWH ::




Custom Search