Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Format and Sort XML with multiple criteria in XSLT

Format and Sort XML with multiple criteria in XSLT

Format and Sort XML with multiple criteria in XSLT

Hi Everybody,

I would like to sort a XML by using multiple criteria.

<?xml version="1.0" ?>
<Exp xsi:schemaLocation="urn:com:ds:config Exp.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:com:ds:cfg">
<Context HolderType="Mod" HolderName="test">
<TreeSeries Type="Prd" Name="test STD">
<Root IsExcluded="false" Name="test STD B" Revision="5"/>
<Root IsExcluded="false" Name="test STD" Revision="TC"/>
<Root IsExcluded="false" Name="test STD" Revision="10"/>
<Root IsExcluded="false" Name="test STD MTC" Revision="5"/>
<Root IsExcluded="false" Name="test STD" Revision="1"/>
<Root IsExcluded="false" Name="test STD" Revision="2"/>
<Root IsExcluded="false" Name="test STD MTC" Revision="6"/>
<Root IsExcluded="false" Name="test STD A" Revision="1"/>
<Root IsExcluded="false" Name="test STD A" Revision="3"/>
<Root IsExcluded="false" Name="test STD MTC" Revision="1"/>
<Root IsExcluded="false" Name="test STD B" Revision="2"/>
<Root IsExcluded="false" Name="test STD C" Revision="1"/>

here should be the result :

"test STD MTC" should appear first in revision order
then other "test STD xx" in alphabetical order for name and ascendant order for revision
then "test STD" order by revision knowing that "TC" need to be display always after revision 2.

test STD MTC - 1
test STD MTC - 5
test STD MTC - 6
test STD A - 1
test STD A - 3
test STD B - 2
test STD B - 5
test STD C - 1
test STD - 1
test STD - 2
test STD - TC
test STD - 10

I try to use xsl:sort but I have too many criteria to order this XML so I think I have to create multiple list to order them as I want but I don't know how to do it.
if someone has an idea ?


RE: Format and Sort XML with multiple criteria in XSLT

You didn't show your XSL so it is hard to know whether you are using XSLT 1.0 or 2.0.

Look at this FAQ FAQ426-6585: Need to group your data? (Use the Muench Method.) for an example that should meet your needs.

Tom Morrison
Hill Country Software

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close