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

Sorting Output

XSLT provides the xsl:sort element to enable you to sort output from a transformation into the order that you want. If you want to sort by two criteria, you can nest xsl:sort elements inside each other.

Listing 12.6 uses the xsl:sort element to output all documents that are final before those that are drafts. Outdated documents are governed by the xsl:otherwise element and are not output.

Listing 12.6. Documents3.xsl: Sorting Documents in Descending Alphabetical Order by version Attribute Value
 <?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:output method="html" indent="yes" /> <xsl:template match="/"> <html> <head> <title>XMML.com Documents</title> <style type="text/css"> ...

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