Changes

Jump to navigation Jump to search
1,220 bytes removed ,  12:08, 26 October 2023
no edit summary
=Conditions=
 
==util:if==
 
{| width='100%'
|- valign="top"
| width='120' | '''Signature'''
|<pre>util:if(
$condition as item()*,
$then as item()*,
$else as item()* := ()
) as item()*</pre>
|- valign="top"
| '''Summary'''
|Alternative writing for the if/then/else expression:
* If the ''effective boolean value'' of {{Code|$condition}} is true, the {{Code|$then}} branch will be evaluated.
* Otherwise, {{Code|$else}} will be evaluated. If no third argument is supplied, an empty sequence will be returned.
|- valign="top"
| '''Examples'''
|
* <code>util:if(true(), 123, 456)</code> returns {{Code|123}}.
* <code>util:if(0, 'wrong!')</code> returns an empty sequence.
|}
 
==util:or==
 
{| width='100%'
|- valign="top"
| width='120' | '''Signature'''
|<pre>util:or(
$items as item()*,
$default as item()*
) as item()*</pre>
|- valign="top"
| '''Summary'''
|Returns {{Code|$items}} if it is a non-empty sequence. Otherwise, returns {{Code|$default}}. Equivalent to the following expressions:
<syntaxhighlight lang="xquery">
if(exists($items)) then $items else $default,
(: Elvis operator :)
$items ?: $default
</syntaxhighlight>
|- valign="top"
| '''Examples'''
|
* <code>util:or(123, 456)</code> returns {{Code|123}}.
* <code>util:or(1[. = 0], -1)</code> returns {{Code|-1}}.
|}
==util:count-within==
=Changelog=
 
;Version 11.0
* Removed: {{Function||util:if}}, {{Function||util:or}}
;Version 9.7
Bureaucrats, editor, reviewer, Administrators
13,551

edits

Navigation menu