Changes

Jump to navigation Jump to search
1,393 bytes added ,  11:24, 10 September 2019
no edit summary
All functions and errors in this module and errors are assigned to the <code><nowiki>http://basex.org/modules/util</nowiki></code> namespace, which is statically bound to the {{Code|util}} prefix.<br/>
=FunctionsConditions=
==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'''
|}
=Positional Access= ==util:item== {{Mark|Updated with Version 9.2}}: Renamed (before: {{Code|util:item-at==}}).
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|util:item-at|$sequence as item()*, $position as xs:double|item()?}}<br/>
|-
| '''Summary'''
| '''Examples'''
|
* <code>util:item-at(reverse(1 to 5), 1)</code> returns <code>5</code>.* <code>util:item-at(('a','b'), 0)</code> returns an empty sequence.
|}
==util:range== {{Mark|Updated with Version 9.2}}: Renamed (before: {{Code|util:item-range==}}).
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|util:item-range|$sequence as item()*, $first as xs:double, $last as xs:double|item()*}}<br/>
|-
| '''Summary'''
| '''Examples'''
|
* <code>util:item-range(//item, 11, 20)</code> returns all path results from (if available) position 11 to 20.
|}
|-
| width='120' | '''Signatures'''
|{{Func|util:last-from|$sequence as item()*|item()?}}<br/>
|-
| '''Summary'''
* <code>util:init(1 to 4)</code> returns <code>1 2 3</code>.
|}
 
=Helper Functions=
==util:replicate==
|
* <code>util:replicate('A', 3)</code> returns <code>A A A</code>.
|}
 
==util:chars==
 
{{Mark|Introduced with Version 9.2:}}
 
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|util:chars|$string as xs:string|xs:string*}}<br/>
|-
| '''Summary'''
|Returns all characters of a {{Code|$string}} as a sequence. Equivalent to <code>string-to-codepoints($string) ! codepoints-to-string(.)</code>.
|-
| '''Examples'''
|
* <code>util:chars('AB')</code> returns the two strings <code>A</code> and <code>B</code>.
|}
 
==util:ddo==
 
{{Mark|Introduced with Version 9.3:}}
 
{| 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>.
|}
=Changelog=
 
;Version 9.3
* Added: [[#util:ddo|util:ddo]]
;Version 9.2
* Added: [[#util:chars|util:chars]], [[#util:init|util:init]]* Updates: [[#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