A RESTful browser for eXist Function Modules


http://exist-db.org/xquery/sort
Creates and manages pre-ordered indexes for use with an 'order by' expression.

sort:create-index($id as xs:string, $nodes as node()*, $values as xs:anyAtomicType*, $options as element()?) item()*
Create a sort index to be used within an 'order by' expression.
$idThe id by which the index will be known and distinguished from other indexes on the same nodes.
$nodesThe node set to be indexed.
$valuesThe 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'/>

sort:create-index-callback($id as xs:string, $nodes as node()*, $callback as function, $options as element()?) item()*
Create a sort index to be used within an 'order by' expression.
$idThe id by which the index will be known and distinguished from other indexes on the same nodes.
$nodesThe node set to be indexed.
$callbackA 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'/>

sort:has-index($id as xs:string) xs:boolean
Check if the sort index, $id, exists.
$idThe name of the index.

Returns true() if the sort index, $id, exists, false() otherwise.

sort:index($id as xs:string, $node as node()?) 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.
$idThe name of the index.
$nodeThe node to look up.

Returns 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($id as xs:string) item()*
Remove a sort index identified by its name.
$idThe name of the index to be removed.

sort:remove-index($id as xs:string, $document-node as node()) item()*
Remove all sort index entries for the given document.
$idThe name of the index to be removed.
$document-nodeA node from the document for which entries should be removed.
Return to list of all modules