Changes

Jump to navigation Jump to search
1,399 bytes added ,  18:50, 18 November 2020
==util:if==
 
{{Mark|Introduced with Version 9.1:}}
{| width='100%'
==util:or==
 
{{Mark|Introduced with Version 9.1:}}
{| width='100%'
|-
| '''Summary'''
|Returns {{Code|$items}} if it is a non-empty sequence. Otherwise, returns {{Code|$default}}. The function is equivalent to one of the expression following expressions:* <code>if(exists($items)) then $items else $default</code>.* <code>$items ?: $default</code> (see [[XQuery Extensions#Elvis Operator|Elvis Operator]] for more details)
|-
| '''Examples'''
==util:item==
 
{{Mark|Updated with Version 9.2}}: Renamed (before: {{Code|util:item-at}}).
{| width='100%'
==util:range==
 
{{Mark|Updated with Version 9.2}}: Renamed (before: {{Code|util:item-range}}).
{| width='100%'
==util:last==
 
{{Mark|Updated with Version 9.2}}: Renamed (before: {{Code|util:last-from}}).
{| width='100%'
==util:init==
 
{{Mark|Introduced with Version 9.2:}}
{| width='100%'
|
* <code>util:init(1 to 4)</code> returns <code>1 2 3</code>.
|}
 
=Node Functions=
 
==util:ddo==
 
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|util:ddo|$nodes as node()*|node()*}}<br/>
|-
| '''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]. All results of path expression are in distinct document order, so the function is equivalent to the expression <code>$nodes/self::node()</code>.
|}
 
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|util:root|$nodes as node()*|document-node()*}}<br/>
|-
| '''Summary'''
|Returns the document nodes of the specified {{Code|$nodes}}. The function is equivalent to the expression <code>$nodes ! /</code>. The path expression <code>/abc</code>
is internally represented as <code>util:root(.)/abc</code.
 
|}
==util:replicate==
 
{{Mark|Updated with Version 9.5:}} Third argument added.
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|util:replicate|$sequence input as item()*, $count as xs:integer|item()*}}<br/>{{Func|util:replicate|$input as item()*, $count as xs:integer, $multiple as xs:boolean|item()*}}
|-
| '''Summary'''
|Returns Evaluates {{Code|$input}} and returns the result {{Code|$count}} instances of the specified times. Unless {{Code|$sequencemultiple}}is enabled, the input expression is only evaluated once. A similar result can be generated with The function call <code>util:replicate($input, $count, true())</code> is equivalent to <code>(1 to $count) ! $sequenceinput</code>, but in the latter case, the right-hand expression will be evaluated multiple times.
|-
| '''Errors'''
|
* <code>util:replicate('A', 3)</code> returns <code>A A A</code>.
* In the following query, a single new element node is constructed, and {{Code|true}} is returned:
<syntaxhighlight lang="xquery">
let $nodes := util:replicate(<node/>, 2)
return $nodes[1] is $nodes[2]
</syntaxhighlight>
* In this query, two nodes are constructed, and the result is {{Code|false}}:
<syntaxhighlight lang="xquery">
let $nodes := util:replicate(<node/>, 2, true())
return $nodes[1] is $nodes[2]
</syntaxhighlight>
|}
==util:chars==
 
{{Mark|Introduced with Version 9.2:}}
{| width='100%'
=Changelog=
 
;Version 9.5
* Updated: [[#util:replicate|util:replicate]]: Third argument added.
 
;Version 9.4
* Added: [[#util:root|util:root]]
 
;Version 9.3
* Added: [[#util:ddo|util:ddo]]
;Version 9.2
* Added: [[#util:chars|util:chars]], [[#util:init|util:init]]
* UpdatesUpdated: [[#util:item|util:item]], [[#util:last|util:last]], [[#util:range|util:range]] renamed (before: {{Code|util:item-at}}, {{Code|util:item-range}}, {{Code|util:last-from}})
;Version 9.1
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu