When sorting in default mode, the sorting is performed using alphabetic string comparisons. If numbers are to be sorted according to their numeric value, data-type must be set to "number".
|
XSLT
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/> <xsl:template match="/"> <number> <xsl:apply-templates select="/aaa/bbb"> <xsl:sort data-type="number"/> </xsl:apply-templates> </number> <default> <xsl:apply-templates select="/aaa/bbb"> <xsl:sort/> </xsl:apply-templates> </default> </xsl:template> <xsl:template match="bbb"> <bbb> <xsl:value-of select="."/> </bbb> </xsl:template> </xsl:stylesheet> |
|
|
XML
<aaa> <bbb>231</bbb> <bbb>111</bbb> <bbb>1</bbb> <bbb>42.1</bbb> <bbb>370</bbb> <bbb>50</bbb> </aaa> |
Output
<number> <bbb>1</bbb> <bbb>42.1</bbb> <bbb>50</bbb> <bbb>111</bbb> <bbb>231</bbb> <bbb>370</bbb> </number> <default> <bbb>1</bbb> <bbb>111</bbb> <bbb>231</bbb> <bbb>370</bbb> <bbb>42.1</bbb> <bbb>50</bbb> </default> |
| Previous chapter: | Number Formatting |
| Next chapter: | Axes |
| Previous page: | Sorting according to case |
| Next page: | Sorting according to several criteria |