O'Reilly logo

Sams Teach Yourself XML in 10 Minutes by Andrew H. Watt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Multiple Sorts

When you use multiple xsl:sort elements, you put the major sort criterion first, then the next most important, and so on if you are using more than two sort criteria.

The xsl:sort element must be a direct child element of the xsl:apply-templates element (in this example). It is an error to nest xsl:sort elements inside each other.

Listing 12.8 shows the XSLT stylesheet modified so that it outputs all (here, both) the final documents first, but those final documents are themselves sorted in ascending alphabetical order.

Listing 12.8. Documents4.xsl: Applying Two Sorts to the Source Document
<?xml version='1.0'?> 
<xsl:stylesheet 
 version="1.0" 
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  > 
<xsl:output method="html" indent="yes" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required