The node element with @id=1 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 therefor 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.
Hopefully the The following example clears things up a bitgives another example. The <entry> element (here it is passed to the expression as a DOM node) can also be replaced by a database node (e.g. copy $c := doc('example')//entry[id='1']). In this case, the original database node remains untouched as all updates are performed on a copy.
<pre class="brush:xquery">
copy $c :=
<entry> <id>1</id> <title>How to use a transform Transform expressionexample</title> <updated>2011-02-23</updated> <author> <name>BaseX Team</name> <uri>http://basex.org</uri> </author> <content type="html">Transform expression example created by BaseX Team</content></entry>
modify (
replace value of node $c//name author with 'BaseX', replace value of node $c//content title with concat('Copy of: ', $c//contenttitle), insert node <memberauthor>Joey</memberauthor> into $c//author
)
return $c