|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Sorting out 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








