Changes

Jump to navigation Jump to search
1,812 bytes added ,  20:07, 25 August 2018
=Updates=
 
==update:apply==
 
{|
|-
| width='120' | '''Signatures'''
|{{Func|update:apply|$function as function(*), $arguments as array(*))|empty-sequence()}}
|-
| '''Summary'''
|The updating variant of [[XQuery 3.1#fn:apply|fn:apply]] applies the specified updating <code>$function</code> to the specified <code>$arguments</code>.
|-
| '''Examples'''
|
* Creates a new database with an initial document and adds a document to an existing database.
<pre class="brush:xquery">
declare %updating function local:update(
$database as xs:string,
$path as xs:string,
$function as %updating function(item(), xs:string) as empty-sequence()
) as empty-sequence() {
update:apply($function, [ $database, $path ])
};
local:update('new-db', 'doc.xml', db:create#2),
local:update('existing-db', 'doc.xml', db:add#2)
</pre>
|}
==update:for-each==
| '''Examples'''
|
* Creates two databasesRenames nodes in an XML snippets:
<pre class="brush:xquery">
copy $xml := <xml><a/><b/></xml>
return $xml
</pre>
|}
 
==update:map-for-each==
 
{| width='100%'
| width='120' | '''Signatures'''
|{{Func|update:map-for-each|$map as map(*), $function as function(xs:anyAtomicType, item()*) as item()*|item()*}}
|-
| '''Summary'''
|The updating variant of {{Function|Map|map:for-each}} applies the specified {{Code|$function}} to every key/value pair of the supplied {{Code|$map}} and returns the results as a sequence.
|-
| '''Examples'''
|
* Inserts attributes into a document:
<pre class="brush:xquery">
copy $doc := <xml/>
modify update:map-for-each(
map {
'id': 'id0',
'value': 456
},
function($key, $value) {
insert node attribute { $key } { $value } into $doc
}
)
return $doc</pre>
|}
==update:output==
{{Mark|Updated with Version 9.01}}: formerly {{Code|db:output}}Maps and arrays can be cached if they contain no persistent database nodes or function items.
{| width='100%'
|-
| '''Summary'''
|This function is a helper function for returning results in an updating expression. The argument of the function will be evaluated, and the resulting items will be cached and returned after the updates on the ''pending update list'' have been processed. As nodes may If the supplied item will be updatedaffected 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()*}}
|-
| '''Summary'''
=Changelog=
 
;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