Changes

Jump to navigation Jump to search
52 bytes added ,  20:45, 5 August 2015
Avoid using "node" as element name in examples because "node" independently appears as a keyword
<pre class="brush:xquery">
delete node //noden
</pre>
The example query deletes all <code><noden></code> elements in your database. Note that, in contrast to other updating expressions, the delete expression allows multiple nodes as a target.
===replace===
<pre class="brush:xquery">
for $n in //nodeoriginalNode
return rename node $n as 'renamedNode'
</pre>
All node <code>originalNode</code> elements are renamed. An iterative approach helps to modify multiple nodes within a single statement. Nodes on the descendant- or attribute-axis of the target are not affected. This has to be done explicitly as well.
==Non-Updating Expressions==
<pre class="brush:xquery">
copy $c := doc('example.xml')//nodeoriginalNode[@id = 1]
modify rename node $c as 'copyOfNode'
return $c
</pre>
The node <code>originalNode</code> element with <code>@id=1</code> is copied and subsequently assigned a new QName using the rename expression. Note that the transform expression is the only expression which returns an actual XDM instance as a result. You can therefore use it to modify results and especially DOM nodes. This is an issue beginners are often confronted with. More on this topic can be found in the [[Update#Returning Results|XQUF Concepts]] section.
The following example demonstrates a common use case:
administrator, editor
43

edits

Navigation menu