Attribute order which is set to the value "descending" enables sorting in reverse order.
|
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="/"> <xsl:apply-templates select="/aaa/bbb"> <xsl:sort select="@x" order="descending"/> </xsl:apply-templates> </xsl:template> <xsl:template match="bbb"> <bbb> <xsl:value-of select="."/> </bbb> </xsl:template> </xsl:stylesheet> |
|
|
XML
<aaa> <bbb x="b">BBB</bbb> <bbb x="d">DDD</bbb> <bbb x="c">CCC</bbb> <bbb x="a">AAA</bbb> </aaa> |
Output
<bbb>DDD</bbb> <bbb>CCC</bbb> <bbb>BBB</bbb> <bbb>AAA</bbb> |
| Previous chapter: | Number Formatting |
| Next chapter: | Axes |
| Previous page: | Select attribute of xsl:sort |
| Next page: | Sorting according to case |