[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

recursive sorting by element name

Subject: recursive sorting by element name
From: "Davis Ford" <davisford@xxxxxxxxx>
Date: Wed, 28 Nov 2007 17:04:05 -0500
 recursive sorting by element name
Hi, consider the following example:

<Collection>
  <CollectionB>
     <B2></B2>
     <A2></A2>
     <A1></A1>
     <B1 typeName="2"></B1>
     <B1 typeName="1"></B1>
  </CollectionB>
  <CollectionA>
     <B2></B2>
     <A2></A2>
     <A1></A1>
     <B1></B1>
  </CollectionA>
</Collection>

I want to sort it as such

<Collection>
  <CollectionA>
      <A1></A1>
      <A2></A2>
      <B1></B1>
      <B2></B2>
  </CollectionA>
  <CollectionB>
      <A1></A1>
      <A2></A2>
      <B1 typeName="1"></B1>
      <B1 typeName="2"></B1>
      <B2></B2>
  </CollectionB>
</Collection>

I am trying to come up with a generic XSLT solution that does not use
explicit element names, but only uses the sort select="name()", and it
should be recursive such that if say, element <A1> contained further
elements, then they would also be sorted by element name.

Finally, if the element names are the same, then it should sort them
by an attribute called "typeName".

Can anyone provide some help?  Thank you in advance!

Regards,
davis

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.