Cited from http://docs.basex.org/wiki/XQuery_Update:
In BaseX, all updates are performed on database nodes or in main
memory. By default, update operations do not affect the original input
file (the info string "Updates are not written back" appears in the
query info to indicate this). The following solutions exist to write
XML documents and binary resources to disk:
- Updates on main-memory instances of files that have been retrieved via fn:doc or fn:collection will be propagated back to disk
when the WRITEBACK option is turned on. This option can also be
activated on command line via -u. Make sure you back up the original
documents before running your queries.
- Functions like fn:put or file:write can be used to write single XML documents to disk. With file:write-binary, you can write binary
resources.
- The EXPORT command can be used write all resources of a databases to disk.
However, if you only need to get the output of an update command you can copy it to a variable (in memory) and transform this variable as follows:
copy $c := doc('t.xq')//entry
modify (
replace value of node $c/author with 'BaseX'
)
return $c
You can also use update
which is a convenience operator for writing simple transform expressions.
doc('t.xq')//entry update replace value of node ./author with 'BaseX'