xsl-list
[Top] [All Lists]

[xsl] Flat DB structure into XML Hierarchy

2007-01-29 08:06:50
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>