Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format and Sort XML with multiple criteria in XSLT

Status
Not open for further replies.

buzz1234

Programmer
Jan 7, 2010
3
FR
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=" xmlns="urn:com:ds:cfg">
<Expression>
<Context HolderType="Mod" HolderName="test">
<TreeSeries Type="Prd" Name="test STD">
<Tree>
<Root IsExcluded="false" Name="test STD B" Revision="5"/>
</Tree>
<Tree>
<Root IsExcluded="false" Name="test STD" Revision="TC"/>
</Tree>
<Tree>
<Root IsExcluded="false" Name="test STD" Revision="10"/>
</Tree>
<Tree>
<Root IsExcluded="false" Name="test STD MTC" Revision="5"/>
</Tree>
<Tree>
<Root IsExcluded="false" Name="test STD" Revision="1"/>
</Tree>
<Tree>
<Root IsExcluded="false" Name="test STD" Revision="2"/>
</Tree>
<Tree>
<Root IsExcluded="false" Name="test STD MTC" Revision="6"/>
</Tree>
<Tree>
<Root IsExcluded="false" Name="test STD A" Revision="1"/>
</Tree>
<Tree>
<Root IsExcluded="false" Name="test STD A" Revision="3"/>
</Tree>
<Tree>
<Root IsExcluded="false" Name="test STD MTC" Revision="1"/>
</Tree>
<Tree>
<Root IsExcluded="false" Name="test STD B" Revision="2"/>
</Tree>
<Tree>
<Root IsExcluded="false" Name="test STD C" Revision="1"/>
</Tree>
</TreeSeries>
</Context>
</Expression>
</Exp>


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 ?

Thanks
 
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 for an example that should meet your needs.

Tom Morrison
Hill Country Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top