RE: How to transform flat structure into hierarchical one?

Subject: RE: How to transform flat structure into hierarchical one?
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Wed, 7 Jun 2000 15:26:43 +0100
> That is why Michael gave you the obvious key to make it
> fast by remarking:
>   "Alternatively, change the SQL query so it does the 
> grouping for you"
> Here he does not mean group as in "GROUP BY" but simply as putting
> related records next to each other as in "ORDER BY". Don't 
> think in SQL all the time - English is trickier than that.
Yes, I was speaking generically. But you can go further than SQL ordering to
make the transformation easy, for example you can start with a SELECT
DISTINCT and put a list of distinct key values at the start of the XML file:
it's then easy to work through the distinct values and for each one use
key() to find all the actual records with that value.

Another way to tackle this problem is not to generate an XML file at all.
Instead the program that queries the database can offer the data to the XSLT
processor as a stream of SAX events. It's then easy for it to slip in extra
startElement and endElement events when the key value changes.

Mike Kay

 XSL-List info and archive:

Current Thread