Sorting the Data

The human mind naturally prefers to have information organized in some sequential order. Even short lists confuse us when they're unorganized. Therefore, sorting functions are the most widely used functions in the selection and presentation of data. Since this applies to XML data as well, there's an option in XSL that will sort the data for presentation.

In this first exercise, you'll use the order-by option to extract the data from the <Catalog> database and sort it in both ascending and descending order.

The XML database file that you'll use in this example is the <Catalog> database from Listing 12.1.

Listing 14.1 is a modification of Listing 12.2. Save it as listing14-1.xsl. The changes are marked in bold.

Listing 14.1 An ...

Get Sams Teach Yourself XML in 24 Hours 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.