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

hierarchical sorting problem

Subject: hierarchical sorting problem
From: Andy_Freeman@xxxxxx
Date: Mon, 6 Oct 2003 15:08:46 -0400
hierarchical sorting
I am trying to sort an XML document by a variety of different attributes.
Here is an example of the source document:

<Result>
  <Product MaterialNumber="494728" Team="ENJ" ActionCode="C1" />
  <Group MaterialNumber="376050" Team="RMT">
    <Product MaterialNumber="376050" Team="RMT" ActionCode="A1" />
    <Product MaterialNumber="376009" Team="RMT" ActionCode="D4" />
  </Group>
  <Product MaterialNumber="70133" ActionCode="" />
  <Group MaterialNumber="75050" Team="RKL">
    <Product MaterialNumber="75050" Team="RKL" ActionCode="J0" />
    <Product MaterialNumber="76009" Team="RKL" ActionCode="A0" />
  </Group>
  <Product MaterialNumber="70309" Team="DDE" ActionCode="A5" />
  <Group MaterialNumber="75051" Team="RKP">
    <Product MaterialNumber="75051" Team="RKP" ActionCode="J1" />
    <Product MaterialNumber="76109" Team="RKP" ActionCode="A4" />
  </Group>
</Result>

I need to sort by the Product ActionCode attribute at either level to
produce the following output:

<Result>
  <Product MaterialNumber="70133" ActionCode="" />
  <Group MaterialNumber="75050" Team="RKL">
    <Product MaterialNumber="76009" Team="RKL" ActionCode="A0" />
    <Product MaterialNumber="75050" Team="RKL" ActionCode="J0" />
  </Group>
  <Group MaterialNumber="376050" Team="RMT">
    <Product MaterialNumber="376050" Team="RMT" ActionCode="A1" />
    <Product MaterialNumber="376009" Team="RMT" ActionCode="D4" />
  </Group>
  <Group MaterialNumber="75051" Team="RKP">
    <Product MaterialNumber="76109" Team="RKP" ActionCode="A4" />
    <Product MaterialNumber="75051" Team="RKP" ActionCode="J1" />
  </Group>
  <Product MaterialNumber="70309" Team="DDE" ActionCode="A5" />
  <Product MaterialNumber="494728" Team="ENJ" ActionCode="C1" />
</Result>

I also need to sort by the Product|Group MaterialNumber attribute to
produce the following output:

<Result>
  <Product MaterialNumber="70133" ActionCode="" />
  <Product MaterialNumber="70309" Team="DDE" ActionCode="A5" />
  <Group MaterialNumber="75050" Team="RKL">
    <Product MaterialNumber="75050" Team="RKL" ActionCode="J0" />
    <Product MaterialNumber="76009" Team="RKL" ActionCode="A0" />
  </Group>
  <Group MaterialNumber="75051" Team="RKP">
    <Product MaterialNumber="75051" Team="RKP" ActionCode="J1" />
    <Product MaterialNumber="76109" Team="RKP" ActionCode="A4" />
  </Group>
  <Group MaterialNumber="376050" Team="RMT">
    <Product MaterialNumber="376009" Team="RMT" ActionCode="D4" />
    <Product MaterialNumber="376050" Team="RMT" ActionCode="A1" />
  </Group>
  <Product MaterialNumber="494728" Team="ENJ" ActionCode="C1" />
</Result>

Note: The example I have shown only has two children per group.  The live
data for this document can have an unlimited number of children.

TIA,
Andy

**********************************************************************
This message is intended only for the designated recipient(s).  It may
contain confidential or proprietary information and may be subject to
the attorney-client privilege or other confidentiality protections.
If you are not a designated recipient, you may not review, use, copy
or distribute this message.  If you receive this in error, please
notify the sender by reply e-mail and delete this message.  Thank you. 

***********************************************************************


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.