xsl-list
[Top] [All Lists]

Re: [xsl] How to "flatten" a XML file with n-ary Cartesian product over n sequences X1, ..., Xn using XSL

2009-08-28 14:10:15
reynaldo(_dot_)rizzo(_at_)aciworldwide(_dot_)com 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/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>