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

dynamic grouping of tabular data; one or two transform

Subject: dynamic grouping of tabular data; one or two transformations?
From: Dan Diebolt <dandiebolt@xxxxxxxxx>
Date: Sat, 24 Nov 2001 06:23:48 -0800 (PST)
dynamic grouping
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

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