|
* Creates a new database with an initial document and adds a document to an existing database.
<syntaxhighlight pre lang="'xquery"'>
declare %updating function local:update(
$database as xs:string,
local:update('new-db', 'doc.xml', db:create#2),
local:update('existing-db', 'doc.xml', db:add#2)
</syntaxhighlightpre>
|}
| width='120' | '''Signature'''
|<pre>update:for-each(
$input as item()*, $action as function(item())as item()*
) as empty-sequence()</pre>
|- valign="top"
|
* Creates two databases:
<syntaxhighlight pre lang="'xquery"'>
let $names := ('db1', 'db2')
return update:for-each($names, db:create#1)
</syntaxhighlightpre>
|}
$input1 as item()*,
$input2 as item()*,
$action as function(item())as item()*
) as empty-sequence()</pre>
|- valign="top"
|
* Renames nodes in an XML snippets:
<syntaxhighlight pre lang="'xquery"'>
copy $xml := <xml><a/><b/></xml>
modify update:for-each-pair(
)
return $xml
</syntaxhighlightpre>
|}
|
* Inserts attributes into a document:
<syntaxhighlight pre lang="'xquery"'>
copy $doc := <xml/>
modify update:map-for-each(
}
)
return $doc</syntaxhighlightpre>
|}
|- valign="top"
| '''Summary'''
|Returns the items that have been cached by {{Function||update:output}}. The output cache can optionally be {{Code|$reset}}. The function can be used to check which items will eventually be returned as the result of an updating function.<br/>This function is ''non-deterministicnondeterministic'': It will return different results before and after items have been cached. The function can be useful for writing [[Unit Module|unit tests]].
|}