<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="dinosaurs">
	<html>
	<head>
	<title>Sorted dinosaurs</title>
	</head>
	<body>
	<h1>My big list of dinosaurs</h1>

	<xsl:apply-templates>					<!-- for all children -->
	    <xsl:sort select="@name" order="descending" />
	</xsl:apply-templates>
	</body></html>
    </xsl:template>


<!--
	To sort by discoverer's name (notice name is first then last), use:

	<xsl:apply-templates>
	    <xsl:sort select="discoverer/text()"/>
	</xsl:apply-templates>


	To sort by discoverer's last name, use:

	<xsl:apply-templates>
	    <xsl:sort select="substring-after(discoverer/text(), ' ')"/>
	</xsl:apply-templates>


	Note - it would have been more sensible to describe the discoverer as:

	<discoverer>
		<firstname>Primrose</firstname>
		<lastname>McFadden</lastname>
	</discoverer>
-->


    <xsl:template match="discoverer">
	<li><b>Discoverer: </b><xsl:value-of select="text()" /></li>
    </xsl:template>


    <xsl:template match="dinosaur">
	<h2><xsl:value-of select="@name"/></h2>

	<xsl:value-of select="description/text()"/>
	<ul>
	    <xsl:apply-templates />		<!-- apply template to each child -->	
	</ul>
    </xsl:template>

    <xsl:template match="weight">
	<li><b>Weight: </b><xsl:value-of select="text()" /> tons</li>
    </xsl:template>

    <xsl:template match="length">
	<li><b>Length: </b><xsl:value-of select="text()" /> m</li>
    </xsl:template>

    <xsl:template match="color">
	<li><b>Color: </b><xsl:value-of select="text()" /></li>
    </xsl:template>

    <!-- 
	suppress the display of all text nodes that are not requested
    -->

    <xsl:template match="text()" /> 

</xsl:stylesheet>