Changes

Jump to navigation Jump to search
1,516 bytes added ,  15:51, 12 December 2017
m
Modified Examples Headline
=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>
|}
administrator, Bureaucrats, editor, Interface administrators, reviewer, Administrators
401

edits

Navigation menu