This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: creating XML hierarchy where not existed before??
- To: xsl-list at lists dot mulberrytech dot com
- Subject: RE: [xsl] creating XML hierarchy where not existed before??
- From: "Meltsner, Kenneth" <Kenneth dot Meltsner at ca dot com>
- Date: Mon, 18 Dec 2000 14:27:51 -0500
- Reply-To: xsl-list at lists dot mulberrytech dot com
It can be solved in XML.
Basically, you can do it with recursion:
For each starting element (e.g. group1), you process it by emitting the start of a element of level n, processing the input element itself, and calling a recursive template to process the following element of level n+1.
The recursive template checks whether the element passed to it is of the n+1 level; if so, it processes it (probably with another pair of a level-x template and a recursive template) and calls itself with the next element. If it's level n, terminate.
Control then returns to the template that called the recursive template, the closing tag of level n is output, and the template ends.
Or something like this:
<level1>
process the group1 element
call-template [process-level1] with the next element
</level1>
process-level1 does the following if:
[group1] -> return without doing anything
[group2] -> process group2, call-template level1 with the next element (forward-sibling)
and so forth. Variations come from whether levels can be missing (a group4 following a group2), multiple group n's in a row, etc.
Ken Meltsner
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list