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

Re: How to "flatten" a XML file with n-ary Cartesian

Subject: Re: How to "flatten" a XML file with n-ary Cartesian product over n sequences X1, ..., Xn using XSL
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Fri, 28 Aug 2009 20:09:09 +0200
Re:  How to "flatten" a XML file with n-ary Cartesian
reynaldo.rizzo@xxxxxxxxxxxxxxxx wrote:

The desired output is a delimited file shown as follows:

'output.csv'
root,itemCode,itemName,aCode,aDescription,bCode,bDescription,cCode,cDescription

That line has nine items while the lines below have only eight items each.


01,name0,10,description0,100,description2,996,description4
01,name0,10,description0,100,description2,997,description5
01,name0,10,description0,200,description3,996,description4
01,name0,10,description0,200,description3,997,description5
02,name1,20,description6,null,null,998,description10
02,name1,20,description6,null,null,999,description11

Output is the Cartesian product of each item with its own sub-sequences.

I've had limited success with my own limited self-learned XSL skills dealing on a per case basis, but I'm not satisfied with the efficiency achieved. Because I have no "normalized" approach, complexity of my XSL grows considerably, related to the number of sequences involved and I'm getting stuck when it involves more than three.

I was wondering if there is any "standard" method that solves this problem for n-sequences (i.e. using a <xsl:for-each-group> that groups by item and repeat the contents for each sublist?) so I could use recursion or iterations according to n. Please note that sequences are optional; the schema allows for empty or nonexistent sequences, where in such cases 'null' must be output for the missing fields.

And what determines the complete number of sequences?


--

	Martin Honnen
	http://msmvps.com/blogs/martin_honnen/

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-2011 All Rights Reserved.