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"> ...

Get Sams Teach Yourself XML in 10 Minutes 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.