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

Sorting by document order of some other element

Subject: Sorting by document order of some other element
From: "Peter Hunsberger" <peter.hunsberger@xxxxxxxxx>
Date: Mon, 25 Jun 2007 15:31:38 -0500
 Sorting by document order of some other element
Hi everyone,

it's been a couple of years since I've had need to consult with all
the wise guru's here, but I've got a question on a sorting problem
that I can't see a simple answer to at the moment.  Basically, I've
got two sets of elements, the element name is unknown but will match
in both sets.  I would like to walk the second set of elements (via a
for-each) and copy them in the order of the corresponding order of the
first set of identically named elements.  There will be an attribute
(say "id") that will have a one to one correspondence between both
sets of elements  .  Eg:

Input:

<doc>
 <set1>
     <element id="4"/>
     <element id="7"/>
     <element id="1"/>
     <element id="3"/>
     <element id="2"/>
 </set1>
 <set2>
     <element id="1">other stuff a</element>
     <element id="4">other stuff b</element>
     <element id="3">other stuff c</element>
     <element id="2">other stuff d</element>
     <element id="7">other stuff e</element>
 </set2>
</doc>

Desired output:

 <set2>
     <element id="4">other stuff b</element>
     <element id="7">other stuff e</element>
     <element id="1">other stuff a</element>
     <element id="3">other stuff c</element>
     <element id="2">other stuff d</element>
 </set2>

Answers can be restricted to XSLT 2.0....

--
Peter Hunsberger

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-2013 All Rights Reserved.