The sort() function

Release 2.0 - ...

The sort() function is an XPath extension function which can be used for sorting node-sets. It is very similar to the exforms sort function.

  CopyCode image Copy Code
node-set sxf:sort(node-set expression, sort expression, language, data-type, order, case-order)

Parameters: 

  • node-set expression: Required XPath expression used to select the nodes which must be sorted.
  • sort expression: Required XPath expression used for selecting the keys on which to sort.
  • language (optional): Specifies the locale used for sorting the keys. Defaults to an empty string, in which case the system environments default locale is used.
  • data-type (optional): Specifies the type of data for sorting purposes: text or number (text is the default).
  • order (optional): Specifies the sorting order: ascending or descending (ascending is the default).
  • case-order: Specifies how to sort uppercase and lowercase letters: none, upperfirst or lowerfirst (upperfirst is the default).

All the parameters are of type string.

Examples

  CopyCode image Copy Code
sxf:sort('//employee','@id','','number','descending')
sxf:sort('//employee','first-name')
sxf:sort('//employee','expenses','','number')

The first expression sorts the employees nodes on the id attribute, using numeric descending sorting rules.
The second expression sorts the employees on their first-name, using default textual & ascending sorting rules.
The third expression sorts the employees on the value of the expenses child-node, using numeric sorting (ascending by default).

Namespace

This function is available within the Smartsite XForms namespace (http://smartsite.nl/namespaces/xforms/1.0).