Changes

Jump to navigation Jump to search
702 bytes added ,  14:20, 20 July 2022
no edit summary
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|util:if|$condition as item()*, $then as item()*|item()*}}<br/>{{Func|util:if|$condition as item()*, $then as item()*, $else as item()*|item()*}}<br/>
|-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'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|util:or|$items as item()*, $default as item()*|item()*}}
|-valign="top"
| '''Summary'''
|Returns {{Code|$items}} if it is a non-empty sequence. Otherwise, returns {{Code|$default}}. Equivalent to the following expressions:
$items ?: $default
</syntaxhighlight>
|-valign="top"
| '''Examples'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|util:count-within|$sequence as item()*, $min as xs:integer|xs:boolean}}<br/>{{Func|util:count-within|$sequence as item()*, $min as xs:integer, $max as xs:integer|xs:boolean}}
|-valign="top"
| '''Summary'''
|Checks if the specified {{Code|$sequence}} has at least {{Code|$min}} and, optionally, at most {{Code|$max}} items. Equivalent to:
return $count >= $min and $count <= $max
</syntaxhighlight>
|-valign="top"
| '''Examples'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|util:item|$sequence as item()*, $position as xs:double|item()?}}<br/>
|-valign="top"
| '''Summary'''
|Returns the item from {{Code|$sequence}} at the specified {{Code|$position}}. Equivalent to:
$sequence[$position]
</syntaxhighlight>
|-valign="top"
| '''Examples'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|util:range|$sequence as item()*, $first as xs:double, $last as xs:double|item()*}}<br/>
|-valign="top"
| '''Summary'''
|Returns items from {{Code|$sequence}}, starting at position {{Code|$first}} and ending at {{Code|$last}}. Equivalent to:
subsequence($sequence, $first, $last - $first + 1)
</syntaxhighlight>
|-valign="top"
| '''Examples'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|util:last|$sequence as item()*|item()?}}<br/>
|-valign="top"
| '''Summary'''
|Returns last item of a {{Code|$sequence}}. Equivalent to:
$sequence[last()]
</syntaxhighlight>
|-valign="top"
| '''Examples'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|util:init|$sequence as item()*|item()*}}<br/>
|-valign="top"
| '''Summary'''
|Returns all items of a {{Code|$sequence}} except for the last one. Equivalent to:
$sequence[position() < last()]
</syntaxhighlight>
|-valign="top"
| '''Examples'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|util:ddo|$nodes as node()*|node()*}}<br/>
|-valign="top"
| '''Summary'''
|Returns nodes in ''distinct document order'': duplicate nodes will be removed, and the remaining nodes will be returned in [https://www.w3.org/TR/xquery-31/#dt-document-order document order]. As results of path expressions are brought distinct document order before they are returned, the function is equivalent to:
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|util:root|$nodes as node()*|document-node()*}}<br/>
|-valign="top"
| '''Summary'''
|Returns the document nodes of the specified {{Code|$nodes}}. The path expression <code>/abc</code> is internally represented as <code>util:root(.)/abc</code. Equivalent to:
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|util:strip-namespaces|$node as node()|node()}}<br/>{{Func|util:strip-namespaces|$node as node(), $prefixes as xs:string*|node()}}<br/>
|-valign="top"
| '''Summary'''
|Removes namespaces with the specified <code>$prefixes</code> from the supplied <code>$node</code>. An empty string can be supplied to remove the default namespace. If no prefixes are specified, all namespaces will be removed.
|-valign="top"
| '''Examples'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|util:array-members|$array as array(*)|array(*)*}}
|-valign="top"
| '''Summary'''
|Returns each member of an {{Code|$array}} as a new array. Equivalent to:
return [ $array($a) ]
</syntaxhighlight>
|-valign="top"
| '''Examples'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|util:array-values|$array as array(*)|item()*}}
|-valign="top"
| '''Summary'''
|Returns all members of an {{Code|$array}} as a sequence. Equivalent to:
$array ? *
</syntaxhighlight>
|-valign="top"
| '''Examples'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|util:map-entries|$map as map(*)|map(xs:string, item()*)*}}
|-valign="top"
| '''Summary'''
|Returns each entry of a {{Code|$map}} as a new map, each with a {{Code|key}} and {{Code|value}} entry. Equivalent to:
})
</syntaxhighlight>
|-valign="top"
| '''Examples'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|util:map-values|$map as map(*)|item()*}}
|-valign="top"
| '''Summary'''
|Returns all values of a {{Code|$map}} as a sequence. Equivalent to:
$map ? *
</syntaxhighlight>
|-valign="top"
| '''Examples'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|util:replicate|$input as item()*, $count as xs:integer|item()*}}<br/>{{Func|util:replicate|$input as item()*, $count as xs:integer, $multiple as xs:boolean|item()*}}
|-valign="top"
| '''Summary'''
|Evaluates {{Code|$input}} and returns the result {{Code|$count}} times. Unless {{Code|$multiple}} is enabled, the input expression is only evaluated once. Equivalent expressions:
(1 to $count) ! $input
</syntaxhighlight>
|-valign="top"
| '''Errors'''
|{{Error|negative|#Errors}} The specified number is negative.
|-valign="top"
| '''Examples'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|util:intersperse|$items as item()*, $separator as item()*|item()*}}
|-valign="top"
| '''Summary'''
|Inserts the defined {{Code|$separator}} between the {{Code|$items}} of a sequence and returns the resulting sequence. Equivalent to:
head($items), for $item in tail($items) return ($separator, $item)
</syntaxhighlight>
|-valign="top"
| '''Examples'''
| Inserts semicolon strings between the three input items:
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|util:duplicates|$sequence as item()*|xs:anyAtomicType*}}<br/>{{Func|util:duplicates|$sequence as item()*, $collation as xs:string|xs:anyAtomicType*}}
|-valign="top"
| '''Summary'''
|Returns duplicate values in a {{Code|$sequence}}. See [https://www.w3.org/TR/xpath-functions-31/#func-distinct-values fn:distinct-values] for the applied equality rules and the usage of the {{Code|$collation}} argument.
|-valign="top"
| '''Examples'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|util:chars|$string as xs:string|xs:string*}}<br/>
|-valign="top"
| '''Summary'''
|Returns all characters of a {{Code|$string}} as a sequence. Equivalent to:
return codepoints-to-string($cp)
</syntaxhighlight>
|-valign="top"
| '''Examples'''
|
! width="110"|Code
|Description
|-valign="top"
|{{Code|negative}}
|The specified number is negative.
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu