Skip to content

XSLT and XQuery for converting an XML tree structure to an HTML table with rowspans

Notifications You must be signed in to change notification settings

evanlenz/tree2table

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

This short XSLT script converts an XML tree structure into an HTML table that uses @rowspan values to "nest" descendants to the right.

Example input:

<root val="root">
  <a val="123">
    <b val="xyz">
      <c val="456"/>
      <c val="789"/>
    </b>
    <b val="abc">
      <c val="def">
        <d val="mno"/>
        <d val="pqr"/>
      </c>
    </b>
  </a>
  <a val="321">
    <b val="654">
      <c val="987"/>
      <c val="ghi"/>
      <c val="jkl"/>
    </b>
  </a>
</root>

Corresponding output:

root 123 xyz 456
789
abc def mno
pqr
321 654 987
ghi
jkl

Source of output:

<table border="1">
   <tr>
      <td rowspan="7">root</td>
      <td rowspan="4">123</td>
      <td rowspan="2">xyz</td>
      <td rowspan="1">456</td>
   </tr>
   <tr>
      <td rowspan="1">789</td>
   </tr>
   <tr>
      <td rowspan="2">abc</td>
      <td rowspan="2">def</td>
      <td rowspan="1">mno</td>
   </tr>
   <tr>
      <td rowspan="1">pqr</td>
   </tr>
   <tr>
      <td rowspan="3">321</td>
      <td rowspan="3">654</td>
      <td rowspan="1">987</td>
   </tr>
   <tr>
      <td rowspan="1">ghi</td>
   </tr>
   <tr>
      <td rowspan="1">jkl</td>
   </tr>
</table>

About

XSLT and XQuery for converting an XML tree structure to an HTML table with rowspans

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages