Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - How to sort different nodes by attribute >Thread Next - Re: How to sort different nodes by attribute Re: How to sort different nodes by attributeTo: NULL Date: 3/5/2008 1:36:00 PM
P_Prdn wrote:
> I use the following xslt, however it didn't give the result I expect:
>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:template match="/Columns/*">
> <xsl:copy>
> <xsl:apply-templates>
> <xsl:sort select="@Seq" order="descending" data-type="number"/>
> </xsl:apply-templates>
> </xsl:copy>
> </xsl:template>
> </xsl:stylesheet>
You need to process the child elements of Columns in sorted order like this:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="Columns">
<xsl:copy>
<xsl:apply-templates select="*">
<xsl:sort select="@Seq" data-type="number"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
