XQuery Function Documentation

Search and Browse

http://exist-db.org/xquery/sort

java:org.exist.xquery.modules.sort.SortModule

Creates and manages pre-ordered indexes for use with an 'order by' expression.

sort:create-index

sort:create-index($id as xs:string, $nodes as node()*, $values as xs:anyAtomicType*, $options as element()?) as item()*

Create a sort index to be used within an 'order by' expression.

Parameters:
$id The id by which the index will be known and distinguished from other indexes on the same nodes.
$nodes* The node set to be indexed.
$values* The values to be indexed. There should be one value for each node in $nodes. $values thus needs to contain as many items as $nodes. If not, a dynamic error is triggered.
$options? <options order='ascending|descending' empty='least|greatest'/>
Returns:
item()* :

sort:create-index-callback

sort:create-index-callback($id as xs:string, $nodes as node()*, $callback as function(*), $options as element()?) as item()*

Create a sort index to be used within an 'order by' expression.

Parameters:
$id The id by which the index will be known and distinguished from other indexes on the same nodes.
$nodes* The node set to be indexed.
$callback A callback function which will be called for every node in the $nodes input set. The function receives the current node as single argument and should return an atomic value by which the node will be sorted.
$options? <options order='ascending|descending' empty='least|greatest'/>
Returns:
item()* :

sort:has-index

sort:has-index($id as xs:string) as xs:boolean

Check if the sort index, $id, exists.

Parameters:
$id The name of the index.
Returns:
xs:boolean : true() if the sort index, $id, exists, false() otherwise.

sort:index

sort:index($id as xs:string, $node as node()?) as xs:long?

Look up a node in the sort index and return a number (&gt; 0) corresponding to the position of that node in the ordered set which was created by a previous call to the sort:create-index function. The function returns the empty sequence if the node cannot be found in the index.

Parameters:
$id The name of the index.
$node? The node to look up.
Returns:
xs:long? : A number &gt; 0 or the empty sequence if the $node argument was empty or the node could not be found in the index.

sort:remove-index

sort:remove-index($id as xs:string) as item()*

Remove a sort index identified by its name.

Parameters:
$id The name of the index to be removed.
Returns:
item()* :

sort:remove-index

sort:remove-index($id as xs:string, $document-node as node()) as item()*

Remove all sort index entries for the given document.

Parameters:
$id The name of the index to be removed.
$document-node A node from the document for which entries should be removed.
Returns:
item()* :