Flat DB structure into XML Hierarchy
Hi there, pretty new to XSLT and wondered if anyone could point me in the right direction. I'm trying to take a flat db structure from a query and transform it into a hierarchical xml structure.
This is the flat structure from the db:
<data>
<row>
<section_depth>1</section_depth>
<section_title>Home</section_title>
</row>
<row>
<section_depth>2</section_depth>
<section_title>Events</section_title>
</row>
<row>
<section_depth>3</section_depth>
<section_title>Event 1</section_title>
</row>
<row>
<section_depth>3</section_depth>
<section_title>Event 2</section_title>
</row>
<row>
<section_depth>2</section_depth>
<section_title>Equipment</section_title>
</row>
<row>
<section_depth>2</section_depth>
<section_title>News</section_title>
</row>
<row>
<section_depth>3</section_depth>
<section_title>News 1</section_title>
</row>
<row>
<section_depth>3</section_depth>
<section_title>News 2</section_title>
</row>
</data>
I'm looking to transform this with XSLT 2, into this using the section_depth as the indentation, can always assume the flat structure will be in the right order:
<site>
<section>
<title>Home</title>
<section>
<title>Events</title>
<section>
<title>Event 1</title>
</section>
<section>
<title>Event 2</title>
</section>
</section>
<section>
<title>Equipment</title>
</section>
<section>
<title>News</title>
<section>
<title>News 1</title>
</section>
<section>
<title>News 2</title>
</section>
</section>
</section>
I've played around with grouping but my head started to hurt. Thanks in advance for any help!
Dave
|