Changes

Jump to navigation Jump to search
455 bytes added ,  12:50, 8 July 2020
no edit summary
|-
| width='120' | '''Signatures'''
|{{Func|update:apply|$function as function(*), $arguments as array(*))|empty-sequence()}}
|-
| '''Summary'''
|
* Creates a new database with an initial document and adds a document to an existing database.
<pre classsyntaxhighlight lang="brush: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)
</presyntaxhighlight>
|}
|-
| width='120' | '''Signatures'''
|{{Func|update:for-each|$seq as item()*, $function as function(item()) as item()*)|empty-sequence()}}
|-
| '''Summary'''
|
* Creates two databases:
<pre classsyntaxhighlight lang="brush:xquery">
let $names := ('db1', 'db2')
return update:for-each($names, db:create#1)
</presyntaxhighlight>
|}
|-
| width='120' | '''Signatures'''
|{{Func|update:for-each-pair|$seq1 as item()*, $function as function(item()) as item()*)|empty-sequence()}}
|-
| '''Summary'''
|
* Renames nodes in an XML snippets:
<pre classsyntaxhighlight lang="brush:xquery">
copy $xml := <xml><a/><b/></xml>
modify update:for-each-pair(
)
return $xml
</presyntaxhighlight>
|}
|
* Inserts attributes into a document:
<pre classsyntaxhighlight lang="brush:xquery">
copy $doc := <xml/>
modify update:map-for-each(
}
)
return $doc</presyntaxhighlight>
|}
==update:output==
 
{{Mark|Updated with Version 9.0}}: formerly {{Code|db:output}}.
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|update:output|$result items as item()*|empty-sequence()}}
|-
| '''Summary'''
|This function can be used if {{Option|MIXUPDATES}} is a helper function for returning results in not enabled, and if values need to returned within an updating expression. : The argument of the function will be evaluated, and the resulting supplied {{Code|$items }} will be cached and returned at the very end, i.e., after the all updates on the ''pending update list'' have been processed. As nodes may be updatedIf one of the supplied items is affected by an update, they a copy will be copied before being created and cachedinstead.
|-
| '''Examples'''
|}
==update:output-cache== {{Mark|Updated with Version 9.0}}: formerly {{Code|db:output-cache}}.
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|update:output-cache||item()*}}<br/>{{Func|update:cache|$reset as xs:boolean|item()*}}
|-
| '''Summary'''
|Returns the items that have been cached by [[#{{Function|Update|update:output}}. The output cache can optionally be {{Code|update:output]]$reset}}. It The function can be used to check which items will eventually be returned as result of an updating function.<br/>This function is ''non-deterministic'': It will return different results before and after items have been cached. It is e. g. useful when writing [[Unit Module|unit tests]].
|}
=Changelog=
 
;Version 9.3
* [[#update:cache|update:cache]]: {{code|$reset}} parameter added.
 
;Version 9.1
* [[#update:output|update:output]]: Maps and arrays can be cached if they contain no persistent database nodes or function items.
 
;Version 9.0
* Updated: db:output renamed to {{Function|Update|update:output}}, db:output-cache renamed to {{Function|Update|update:cache}}
This module was introduced with Version 9.0.
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu