As described in the April 2003 issue of CPU - Computer Power User magazine. This article builds on the examples described in the March 2003 issue. These examples are found here (http://www.iangraham.org/writing/cpu-articles/mar03/)
<xsl:for-each select="/data/item" > <xsl:sort select="name" /> <xsl:apply-templates select="." /> </xsl:for-each>This almost gets it right, but messes up the first item (because of leading whitespace). A plain text version is available at transform-sort1.txt.
<xsl:for-each select="/data/item" > <xsl:sort select="normalize-space(name)" /> <xsl:apply-templates select="." /> </xsl:for-each>This works properly, because the normalize-space() function removes the leading space characters from the values. A plain text version is available at transform-sort2.txt.
<xsl:apply-templates select="/data/item" > <xsl:sort select="normalize-space(name)" /> </xsl:apply-templates>This almost gets it right, but messes up the first item (because of leading whitespace). A plain text version is available at transform-sort3.txt.
<xsl:for-each select="/data/item" > <xsl:sort data-type="number" select="substring(normalize-space(birthday),string-length(normalize-space(birthday))-3,4)" /> <xsl:apply-templates select="." /> </xsl:for-each>This works fine -- but only if each birthday string actually ends with a four-digit year! plain text version is available at transform-sort4.txt.