declare namespace xmldb="http://exist-db.org/xquery/xmldb";
declare namespace util="http://exist-db.org/xquery/util";
declare function local:update() as element()*
{
let $maxId := max(for $i in //node/@id return xs:integer($i)) + 1
let $collection := xmldb:collection('xmldb:exist:///db/C1', 'guest', 'guest')
let $update1 :=
appended node - guest A
let $update2 :=
appended node - guest B
return
{$maxId},{xmldb:update($collection, $update1)},{xmldb:update($collection, $update2)}
};
for $i in (1,2,3,4,5,6,7,8,9,10)
let $doc := (doc('/db/C1/test.xml'),doc('/db/C1/test2.xml'))
let $j := util:exclusive-lock($doc,local:update() )
let $k := util:exclusive-lock($doc,local:update() )
return ($j,$k)