Changes

Jump to navigation Jump to search
19 bytes added ,  16:22, 7 August 2022
<syntaxhighlight lang="xquery">
(: if/then/else :)if ($test ok) then 1 else 0,(: ternary if :)$ok ?? 'ok' 1 !! 'fails'0
</syntaxhighlight>
<syntaxhighlight lang="xquery">
let $number := 123return ( (: if/then/else :) if (exists($numberargument)) then $number argument else 0, (: elvis operator :) $number argument ?: 0)-1
</syntaxhighlight>
<syntaxhighlight lang="xquery">
if ($a) then if($b) then '$a and $b is true' else 'only $b a is true'
</syntaxhighlight>
<syntaxhighlight lang="xquery">
if ($a) then (
if($b) then '$a and $b is true' else 'only $b a is true'
)
</syntaxhighlight>
<syntaxhighlight lang="xquery">
declare option db:chop catalog 'falseetc/w3-catalog.xml';
doc('doc.xml')
</syntaxhighlight>
(# db:enforceindex #) {
for $db in ('persons1', 'persons2', 'persons3')
return db:openget($db)//name[text() = 'John']
}
</syntaxhighlight>
'wrapped-db-nodes.xml',
(# db:copynode false #) {
<xml>{ db:openget('huge') }</xml>
}
)
'''Example:'''
<syntaxhighlight lang="xquery">
declare %basex:lazy variable $january := doc('does-not-exist.xml');
if(month-from-date(current-date()) = 1) then $january else ()
</syntaxhighlight>
The annotation ensures that an error will is only be raised if the condition yields true. Without the annotation, the error will is always be raised, because if the referenced document is not found.
==XQuery Locks==
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu