Changes

Jump to navigation Jump to search
1,287 bytes added ,  14:42, 12 December 2017
no edit summary
Except for [[#update:output-cache|update:output-cache]], all functions are ''updating'' and thus comply to the XQuery Update constraints.
 
=Updates=
 
==update:for-each==
 
{|
|-
| width='120' | '''Signatures'''
|{{Func|update:for-each|$seq as item()*, $function as function(item()) as item()*)|empty-sequence()}}
|-
| '''Summary'''
|The updating variant of [[Higher-Order Functions#fn:for-each|fn:for-each]] applies the specified updating <code>$function</code> to every item of <code>$seq</code>.
|-
| '''Examples'''
|
* Creates two databases:
<pre class="brush:xquery">
let $names := ('db1', 'db2')
return update:for-each($names, db:create#1)
</pre>
|}
 
==update:for-each-pair==
 
{|
|-
| width='120' | '''Signatures'''
|{{Func|update:for-each-pair|$seq1 as item()*, $function as function(item()) as item()*)|empty-sequence()}}
|-
| '''Summary'''
|The updating variant of [[Higher-Order Functions#fn:for-each-pair|fn:for-each-pair]] applies the specified updating <code>$function</code> to the successive pairs of items of <code>$seq1</code> and <code>$seq2</code>. Evaluation is stopped if one sequence yields no more items.
|-
| '''Examples'''
|
* Creates two databases:
<pre class="brush:xquery">
copy $xml := <xml><a/><b/></xml>
modify update:for-each-pair(
('a', 'b'),
('d', 'e'),
function($source, $target) {
for $e in $xml/*[name() = $source]
return rename node $e as $target
}
)
return $xml
</pre>
|}
=Output=
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu