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

Flat DB structure into XML Hierarchy

Subject: Flat DB structure into XML Hierarchy
From: "Dave Quested" <dave.quested@xxxxxxxxx>
Date: Mon, 29 Jan 2007 15:06:28 +0000
 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

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.