Ordering options

Some options are available for changing the default sorting behaviour in some limited ways. Attributes on the Sort element are used to specify these changes.

Numerical ordering

It is possible to sort by numerical value. This is very different from sorting by characters when the characters happen to be digits. Normal sorting simply ranks digits by their ASCII value:

<P>1999</P>
<P>29</P>
<P>399</P>

In this example, '1999' is the first item because it begins with a '1'. But the numbers are clearly not ranked by value, as '1999' is larger than '29', which is smaller than '399'. Ordering by value can be achieved using the Data Type attribute. It has a default value of 'text', but can be given an explicit value of 'number'. The values are then ranked in ascending order:

<sort data-type="number"/>


   <P>39</P>
   <P>299</P>
   <P>1999</P>

Although the XSLT standard makes no comment on this point, a value test should not fail if the text string contains letters as well as digits, even if there is no space between them. The number should be constructed from the first unbroken series of digits:

<P>1xyz</P>
<P>22</P>
<P>333abc99</P>

Letter-case ordering

Capital letters can be placed above lower-case letters using the Case Order attribute. This attribute can only take two possible values; 'lower-first' (the default) or 'upper-first'.

<sort case-order="upper-first"/>


   <P>Abc - ...</P>
   <P>abc - ...</P>

This attribute is only relevant when the Data Type attribute has an implied (or explicit) value of 'text'.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset