XSL Transform Tree into Table

Discussion in 'XML' started by Daniel Hirscher, Jan 27, 2004.

  1. Hi,

    I like to transform a XML hierarchical tree structure into a HTML
    Table.
    All leaves are on the same depth of the tree. Every tree will give a
    correct table without empty cells. The number of elements in one
    hierarchy level can be more than two.

    My problem is that I have to go into tree-depth and table-width at the
    same time. Calculation of colspan is no problem.

    How can I solve this recursively?

    Example:

    XML look like this:

    <tree>
    <sub name="1">
    <sub name="2">
    <sub name="3"/>
    <sub name="4"/>
    </sub>
    <sub name="5">
    <sub name="6"/>
    <sub name="7"/>
    </sub>
    </sub>
    <sub name="8">
    <sub name="9">
    <sub name="10"/>
    <sub name="11"/>
    </sub>
    <sub name="12">
    <sub name="13"/>
    <sub name="14"/>
    </sub>
    </sub>
    </tree>

    HTML should look like this:

    <table border="1">
    <tr>
    <td colspan="4">1</td>
    <td colspan="4">8</td>
    </tr>
    <tr>
    <td colspan="2">2</td>
    <td colspan="2">5</td>
    <td colspan="2">9</td>
    <td colspan="2">12</td>
    </tr>
    <tr>
    <td>3</td>
    <td>4</td>
    <td>6</td>
    <td>7</td>
    <td>10</td>
    <td>11</td>
    <td>13</td>
    <td>14</td>
    </tr>
    </table>
     
    Daniel Hirscher, Jan 27, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. KathyB
    Replies:
    0
    Views:
    1,035
    KathyB
    Jun 25, 2003
  2. Replies:
    3
    Views:
    2,926
    Bruce Barker
    Sep 8, 2005
  3. Marrow
    Replies:
    0
    Views:
    4,155
    Marrow
    Jul 2, 2003
  4. Replies:
    1
    Views:
    3,636
    A. Bolmarcich
    May 27, 2005
  5. Stub

    B tree, B+ tree and B* tree

    Stub, Nov 12, 2003, in forum: C Programming
    Replies:
    3
    Views:
    10,172
Loading...

Share This Page