Subject: [xsl] dynamic grouping of tabular data; one or two transformations? From: Dan Diebolt <dandiebolt@xxxxxxxxx> Date: Sat, 24 Nov 2001 06:23:48 -0800 (PST) |
I have a tablular set of data: A B C D 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1 represented in XML as follows: <root> <row> <A>0</A> <B>0</B> <C>0</C> <D>0</D> </row> <row> <A>0</A> <B>0</B> <C>0</C> <D>1</D> </row> <row> <A>0</A> <B>0</B> <C>1</C> <D>0</D> </row> <row> <A>0</A> <B>0</B> <C>1</C> <D>1</D> </row> ... <row> <A>1</A> <B>1</B> <C>1</C> <D>1</D> </row> </root> I need to produce various grouped and indented views of this data on demand. For example, if I group on {A} I would like this output: A B C D 0 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 1 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 If I grouped on {A,B} I would like this output: A B C D 0 0 0 0 0 1 1 0 1 1 1 0 0 0 1 1 0 1 1 1 0 0 0 0 1 1 0 1 1 1 0 0 0 1 1 0 1 1 And if I grouped on {A,C} I would like this output: A C B D 0 0 0 0 0 1 1 0 1 1 1 0 0 0 1 1 0 1 1 1 0 0 0 0 1 1 0 1 1 1 0 0 0 1 1 0 1 1 And just for completeness, if I grouped on {} I would like this output: A B C D 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1 For any specific grouping, I can define keys and apply Meunch's technique. But I would like the XSLT to apply to any tabular arrangement of data not just one with specific element names (ie <A>, <B>, <C> or <D>). So I would like to a parameter named "GroupBy" with values like "A", "A,B", "A,C" or "" to define the desired table grouping. All of the above examples would be rendered as html tables with empty cells for the grouping and indention shown here for GroupBy="A,B" <table> <tr><th>A</th><th>B</th><th>C</th><th>D</th></tr> <tr><td>0</td><td>0</td><td>0</td><td>0</td></tr> <tr><td> </td><td> </td><td>0</td><td>1</td></tr> <tr><td> </td><td> </td><td>1</td><td>0</td></tr> <tr><td> </td><td> </td><td>1</td><td>1</td></tr> <tr><td> </td><td>1</td><td>0</td><td>0</td></tr> ... <tr><td>1</td><td>0</td><td>0</td><td>0</td></tr> ... <tr><td> </td><td> </td><td>1</td><td>1</td></tr> </table> So here is my question to the list: Is it possible to do this with *one* stylesheet transformation? I can't see a way to generate the required grouping keys dynamically. My thinking is to first generate a stylesheet with the required key definitions and essential transformation code and then transform the original XML source with this generated stylesheet: xsl2 = xml.transformNode(xsl1); html = xml.tranformNode(xsl2); Any ideas would be appreciated. Thanks. __________________________________________________ Do You Yahoo!? Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month. http://geocities.yahoo.com/ps/info1 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] positional predicates in , Howard Katz | Thread | Re: [xsl] dynamic grouping of tabul, Jeni Tennison |
RE: [xsl] document fragments as par, Chris Bayes | Date | Re: [xsl] dynamic grouping of tabul, Jeni Tennison |
Month |