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()?) as item()*
Create a sort index to be used within an 'order by' expression.
$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'/> |
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.
$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'/> |
sort:has-index($id as xs:string) as xs:boolean
Check if the sort index, $id, exists.
$id | The name of the 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 (> 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.
$id | The name of the index. |
$node? | The node to look up. |
sort:remove-index($id as xs:string) as item()*
Remove a sort index identified by its name.
$id | The name of the index to be removed. |
sort:remove-index($id as xs:string, $document-node as node()) as item()*
Remove all sort index entries for the given document.
$id | The name of the index to be removed. |
$document-node | A node from the document for which entries should be removed. |