Re: [xsl] <xsl:sort>

Subject: Re: [xsl] <xsl:sort>
From: George Cristian Bina <george@xxxxxxx>
Date: Sat, 07 May 2005 11:31:21 +0300
XML:
<?xml version="1.0" encoding="UTF-8"?>
<document>
    <header/>
    <paragraph/>
    <subheader/>
    <paragraph/>
    <product>
        <partname/>
        <category>3</category>
    </product>
    <product>
        <partname/>
        <category>1</category>
    </product>
    <product>
        <partname/>
        <category>2</category>
    </product>
</document>

XSL:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
<xsl:template match="document">
<xsl:for-each select="child::node()">
<!-- whatever processing you want to do -->
</xsl:for-each>
<xsl:apply-templates select="product">
<xsl:sort select="category" data-type="number" order="descending"/>
</xsl:apply-templates>
</xsl:template>
</xsl:stylesheet>


All the XSLT transformers I tried (Saxon6.5.3, Saxon 8.4, Xalan 2.5.1, MSXML .NET, 4.0, 3.0 and XSLTProc) gave me:
3
2
1


Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com


aspsa wrote:
Thanks for the reply, George.

I gave your suggestion a try, but it still does not affect the sort order of
<product> elements. In the resultant document, they continue to appear in
the orginal XML document order.


Respectfully,


ASP

Current Thread