XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition (236 page)

BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
8.48Mb size Format: txt, pdf, ePub
  • Last but not least, if the two values are strings, then they are compared using a collation. Collations are a broad subject so we will devote a separate section to them.

The
order
attribute specifies whether the order is ascending or descending. Descending order will produce the opposite result of ascending order. This means, for example, that NaN values will appear last rather than first, and also that the effect of the
case-order
attribute is reversed: If you specify
case-order=“upper-first”
with
order=“descending”
, then
drall
will come before
Drall
.

The final sorted order of the items determines the sequence in which they are processed by the containing

,

, or

instruction, or the order in which they are returned by the containing

instruction. While the sorted sequence is being processed, the value of
position()
will reflect the position of the current item in the sorted sequence.

Collations

When the sort key values to be compared are strings, they are compared using a collation. A collation is essentially a mechanism for deciding whether two strings such as
polish
and
Polish
are considered equal, and if not, which of them should come first.

Choosing the right collation depends on the data that you are sorting, and on the expectations of the users. These expectations vary by country (in Germany, in most modern publications,
ä
is sorted along with
a
, but in Sweden, it is sorted after
z
) and also vary according to the application. Telephone directories, dictionaries, gazetteers, and back-of-book indexes each have their own rules.

Other books

The Christmas Tree by Salamon, Julie; Weber, Jill;
Gracie's Sin by Freda Lightfoot
Backstage with Her Ex by Louisa George
You Know Who Killed Me by Loren D. Estleman
Woman in the Window by Thomas Gifford