You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Cory Isaacson <ci...@capita2.com> on 2000/11/02 18:37:21 UTC
Sort Example
I need to sort a document, and output it in its entirety. Does this look reasonable?
Thanks,
Cory
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">
<xsl:template match="/">
<!-- Primary Sort by a non-numeric element, ascending.-->
<xsl:sort order="ascending" select="elem1[@attrib1='2']" />
<!-- Secondary Sort by a numeric element, descending.-->
<xsl:sort order="descending" data-type="number" select="elem1[@attrib1='5']" />
</xsl:template>
<!-- Copy the entire document to the output.-->
<xsl:template match="*|@*|comment()|pi()|text()">
<xsl:copy>
<xsl:apply-templates select="*|@*|comment()|pi()|text()"
</xsl:copy>
</xsl:template>