Selective sorting

The examples above all assume that the sort order value is the entire content of the elements to be sorted. The Select attribute can be used to identify a more specific item to be used as the sort value. The implied value of this attribute is '.', indicating the current element. The following examples are equivalent:

<sort/>


<sort select="."/>

The current element, in this context, means the element being sorted, and it applies to each one of these elements in turn.

As usual, this attribute can take any XPath expression, greatly improving the flexibility of the sort feature.

Child element selection

Elements that contain other elements can be sorted, and the sorting criteria can be specified to be the content of one of the sub-elements. ...

Get XSL companion, The now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.