Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


How to sort different nodes by attribute

From: PPrdn@-----------.---------.---
To: NULL
Date: 3/4/2008 11:36:00 AM

I store my database settings in xml as follows:

<?xml version="1.0" encoding="utf-8" ?>
<Columns>
  <F1 Seq="0" />
  <F2 Seq="1" />
  <F3 Seq="3" />
  <F4 Seq="9" />
  <F5 Seq="2" />
  <F6 Seq="4" />
  <F7 Seq="8" />
  <F8 Seq="5" />
  <F9 Seq="7" />
  <F10 Seq="6" />
</Columns>

I'd like to have the user sort the column order, so the resulting xml will 
look like:

<?xml version="1.0" encoding="utf-8" ?>
<Columns>
  <F1 Seq="0" />
  <F2 Seq="1" />
  <F5 Seq="2" />
  <F3 Seq="3" />
  <F6 Seq="4" />
  <F8 Seq="5" />
  <F10 Seq="6" />
  <F9 Seq="7" />
  <F7 Seq="8" />
  <F4 Seq="9" />
</Columns>

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>

I'm new to xslt, I'd appreciate if anyone could show me how to create the 
xslt to address this problem.

Thanks,
P_Prdn





transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent