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

Transforming tabular information to hierarchical

Subject: Transforming tabular information to hierarchical
From: "Simon Shutter" <simon@xxxxxxxxxxx>
Date: Tue, 13 Feb 2007 08:32:22 -0800
 Transforming tabular information to hierarchical
If I have a tabular data set that defines parent-child relationships, is it
possible to transform this into a hierarchical tree format using XSLT?

eg source:

ID	ParentID	Name	col1	col2	col3
1	null		One	bla1	bla1	bla1
2	1		Two	bla2	bla2	bla2
3	2		Three	bla3	bla3	bla3
4	3		Four	bla4	bla4	bla4
5	1		Five	bla5	bla5	bla5
6	4		Six	bla6	bla6	bla6
7	4		Seven	bla7	bla7	bla7
8	7		Eight	bla8	bla8	bla8
9	3		Nine	bla9	bla9	bla9
10	9		Ten	bla10	bla10	bla10

desired output:

<?xml version="1.0" encoding="utf-8"?>
<ul id='root' xmlns:bla="http://www.blablabla.com/bla">
  <li id='1' bla:col1='bla1' bla:col2='bla1' bla:col3='bla1'>
    One
    <ul>
      <li bla:col1='bla2' bla:col2='bla2' bla:col3='bla2'>
        Two
        <ul>
        <li bla:col1='bla3' bla:col2='bla3' bla:col3='bla3' />Three
        <ul>
          <li id='4' bla:col1='bla4' bla:col2='bla4' bla:col3='bla4' />Four
          <ul>
            <li id='6' bla:col1='bla6' bla:col2='bla6'
bla:col3='bla6'>Six</li>
            <li id='7' bla:col1='bla7' bla:col2='bla7' bla:col3='bla7'>
              Seven
              <ul>
                <li id='8' bla:col1='bla8' bla:col2='bla8'
bla:col3='bla8'>Eight</li>
              </ul>
            </li>
          </ul>
          <li id='9' bla:col1='bla9' bla:col2='bla9' bla:col3='bla9'>
            Nine
            <ul>
              <li id='10' bla:col1='bla10' bla:col2='bla10'
bla:col3='bla10'>Ten</li>
            </ul>
          </li>
        </ul>
      </ul>
      </li>
      <li id='5' bla:col1='bla5' bla:col2='bla5' bla:col3='bla5'>Five</li>
    </ul>
  </li>
</ul>


Thanks, Simon

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.