Code:
For example, suppose an employee database has the following form.
<employees>
<employee>
<name>
<given>James</given>
<family>Clark</family>
</name>
...
</employee>
</employees>
A list of employees sorted by name could be generated using the following.
<xsl:template match="employees">
<ul>
<xsl:apply-templates select="employee">
<xsl:sort select="name/family"/>
<xsl:sort select="name/given"/>
</xsl:apply-templates>
</ul>
</xsl:template>
<xsl:template match="employee">
<li>
<xsl:value-of select="name/given"/>
<xsl:text> </xsl:text>
<xsl:value-of select="name/family"/>
</li>
</xsl:template>