delete node //
The example query deletes all <code><
node></code> elements in your database. Note that, in contrast to other updating expressions, the delete expression allows multiple nodes as a target.
for $n in //
return rename node $n as 'renamedNode'
node 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.
copy $c := doc('example.xml')//
node[@id = 1]
modify rename node $c as 'copyOfNode'
node 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: