This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Sorting out doublettes...
- To: xsl-list at lists dot mulberrytech dot com
- Subject: [xsl] Sorting out doublettes...
- From: Christian Cäsar <caesar at mpdigital dot de>
- Date: Tue, 23 Oct 2001 12:20:34 +0200
- Reply-To: xsl-list at lists dot mulberrytech dot com
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