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

Sorting out doublettes...

Subject: Sorting out doublettes...
From: Christian Cäsar <caesar@xxxxxxxxxxxx>
Date: Tue, 23 Oct 2001 12:20:34 +0200
doublettes
Hello all,

I have an XML file and want to convert it to another XML file.

The basic source XML is (simplified):

<root>
<Product>
 <ID value="someuniquevalue1"></ID>
 <accessory/>
</Product>
<Product>
 <ID value="someuniquevalue2"></ID>
 <accessory>
  <Product>
   <ID value="someuniquevalue1"></ID>
   <accessory/>
  </Product>
 </accessory>
</Product>
<Product>
 <ID value="someuniquevalue3"></ID>
 <accessory/>
</Product>
<Product>
 <ID value="someuniquevalue4"></ID>
 <accessory>
  <Product>
   <ID value="someuniquevalue5"></ID>
   <accessory/>
  </Product>
 </accessory>
</Product>
</root>

That is, a product CAN contain an accessory, which is in itself a product.
This is not recursive. Products can also be both an accessory AND a
standalone product, which means they appear twice in the source, once as a
standalone, once in an accessory section of another product. It's also
possible that a product appears ONLY in the accessory section.

I want to grab all products and accessories exactly once and do some
transformations on them. Sadly I fail to filter the doublettes. This is how
I grab the Products:

  <xsl:apply-templates select="*[not(parent::accessory)]/Product"/>

(getting all products that are not accessories)

Then I do

  <xsl:apply-templates select="//accessory/Product"/>

(getting all accessories)

How can I sort out all doublettes? Must I take another approach?

Changing the source XML is not an option unfortunately.

Thanks for your help,
Christian

 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.