xsl:sort
Used within an xsl:for-each, xsl:apply-templates, xsl:for-each-group, or xsl:perform-sort to indicate the order in which the selected elements are processed.
Content:
sequence-constructor
Permitted parent elements:
xsl:apply-templates
; xsl:for-each
; xsl:for-each-group
; xsl:perform-sort
Attributes
|
|
A string expression that calculates the sort key. Default value ".". |
|
|
Determines the algorithm used for alphabetic
collating, as an ISO language code such as |
|
|
Determines the sort order (the default is
|
|
|
The name of a collating sequence. If
present it must be a collation URI that uses the scheme and path
|
|
|
|
|
|
Relevant only for
|
|
|
Determines whether collating is based on
alphabetic sequence or numeric sequence. The permitted values are either
|
Details
When using the Unicode Collation Algorithm, only the order
and
data-type
control attributes are relevant - all other controls
are attached as query parameters to the collation URI.
Several sort keys are allowed: they are written in major-to-minor order.
Examples
Example 1
Sorting with xsl:apply-templates
. This example shows a template
for a <BOOKLIST>
element which processes all the child
<BOOK>
elements in order of their child
<AUTHOR>
elements; books with the same author are in
descending order of the DATE
attribute.
Example 2
Sorting with xsl:for-each
. This example also shows a template
for a <BOOKLIST>
element which processes all the child
<BOOK>
elements in order of their child
<AUTHOR>
elements.
Example 3
Sorting with xsl:for-each
using Unicode Collation Algorithm.
<BOOK>
elements are processed in order of their child
<TITLE>
elements, sorted as if they were in French
dictionary order (where accents are compared in a reverse direction).