Changes

Jump to navigation Jump to search
2,513 bytes added ,  14:34, 3 March 2016
Created page with "This XQuery Module contains various small utility and helper functions. Please note that some of the functions are used for internal query rewritings. They may..."
This [[Module Library|XQuery Module]] contains various small utility and helper functions. Please note that some of the functions are used for internal query rewritings. They may be renamed or moved to other modules in future versions of BaseX.

=Conventions=

All functions 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/>

=Function Items=

==util:function-annotations==

{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|util:function-annotations|$function as function(*)?|map(xs:QName, xs:anyAtomicType*)}}<br/>
|-
| '''Summary'''
|Returns the annotations of the specified {{Code|$function}} in a map.
|-
| '''Examples'''
|
* Returns an empty map:
<pre class="brush:xquery">
util:function-annotations(true#0)
</pre>
* Returns a map with a single key <code><nowiki>Q{http://www.w3.org/2012/xquery}private</nowiki></code> and an empty sequence as value:
<pre class="brush:xquery">
declare %private function local:f() { 'well hidden' };
util:function-annotations(local:f#0)
</pre>
|}

=Sequences=

==util:item-at==

{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|util:item-at|$sequence as item()*, $position as xs:double|item()?}}<br/>
|-
| '''Summary'''
|Returns the item from {{Code|$sequence}} at the specified {{Code|$position}}. Equivalent to <code>$sequence[$position]</code>.
|-
| '''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: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'''
|Returns items from {{Code|$sequence}}, starting at position {{Code|$first}} and ending at {{Code|$last}}. Equivalent to <code>subsequence($sequence, $first, $last - $first + 1)</code>.
|-
| '''Examples'''
|
* <code>util:item-range(//item, 11, 20)</code> returns all path results from (if available) position 11 to 20.
|}

==util:last-from==

{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|util:last-from|$sequence as item()*|item()?}}<br/>
|-
| '''Summary'''
|Returns last item of a {{Code|$sequence}}. Equivalent to <code>$sequence[last()]</code>.
|-
| '''Examples'''
|
* <code>util:last-from(reverse(1 to 100))</code> returns <code>1</code>.
|}

=Changelog=

The Module was introduced with Version 8.5.
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu