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

Grouping - Combining Nodes

Subject: Grouping - Combining Nodes
From: Doug Rudder <drudder@xxxxxxxxxxxxx>
Date: Fri, 16 Dec 2005 09:21:44 -0600
infective sages
Venerable XSLT Sages -

I'm using XSLT 1.0 to pull content from an XML data set to build a class
index. I've solved the first two pieces of the puzzle: Extract the
information from each drug topic and sort the index by class-name. However,
I'm bogged down and the third part: When multiple index entries have the
same class-name, combine them into a single index entry.

For example, in the snippet below, there are four class-items, sorted
alphabetically. The middle two have the same class name:

<class-index>
   <class-item>
      <class-name>Aminoglycoside</class-name>
      <class-reflist>
         <class-ref xref="fandc-atoz0479">Kanamycin Sulfate</class-ref>
      </class-reflist>

   </class-item>
   <class-item>
      <class-name>Analgesic</class-name>
      <class-reflist>
         <class-ref xref="fandc-atoz0483">Ketoprofen</class-ref>
      </class-reflist>
   </class-item>

   <class-item>
      <class-name>Analgesic</class-name>
      <class-reflist>
         <class-ref xref="fandc-atoz0484">Ketorolac Tromethamine</class-ref>
      </class-reflist>
   </class-item>

   <class-item>
      <class-name>Anti-infective</class-name>
      <class-reflist>
         <class-ref xref="fandc-atoz0482">Ketoconazole</class-ref>
      </class-reflist>
   </class-item>
</class-index>

I would like to combine those two into a single class-item that references
all related drug topics (basically move all related class-ref elements into
the same class-item under the class-name):

<class-index>
   <class-item>
      <class-name>Aminoglycoside</class-name>
      <class-reflist>
         <class-ref xref="fandc-atoz0479">Kanamycin Sulfate</class-ref>
      </class-reflist>
   </class-item>

   <class-item>
      <class-name>Analgesic</class-name>
      <class-reflist>
         <class-ref xref="fandc-atoz0483">Ketoprofen</class-ref>
         <class-ref xref="fandc-atoz0484">Ketorolac Tromethamine</class-ref>
     </class-reflist>
   </class-item>

   <class-item>
      <class-name>Anti-infective</class-name>
      <class-reflist>
         <class-ref xref="fandc-atoz0482">Ketoconazole</class-ref>
      </class-reflist>
   </class-item>
</class-index>

Can this be done in XSLT 1.0. If so, how? Any tips will be appreciated.

=======================
Douglas Rudder
XML Analyst
WoltersKluwer Health - Clinical Tools
77 West Port Plaza, Suite 450
Phone:  314-216-2227
e-mail:  drudder@xxxxxxxxxxxxx
www.drugfacts.com
=======================

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.