I would like to transform an XML document using xslt with a set of row nodes and column nodes into an xhtml table.
The column nodes define data about the associated row attribute. For example, the first column node specifies that the ID attribute of the Row node should be hidden (i.e. not show up in the table). The Caption element of the Column node defines what the column header text should be.
I’ve seen solutions where you know the attributes that you want to turn into columns ahead of time, but I’m not sure how to use the relevant column data to format the headers
Input:
<TableData>
<Columns>
<Column Name="ID" Hidden="true" />
<Column Name="Name" Caption="Item Name" />
<Column Name="Desc" Caption="Item Description" />
</Columns>
<Rows>
<Row ID="0" Name="A" />
<Row ID="1" Name="B" Desc="Some description"/>
<Row ID="3" Name="C" />
</Rows>
</TableData>
Desired output would be a table in (x)html something like this:
Item Name | Item Description
--------------------------------------
A |
B | Some Description
C |
This transformation:
when applied on the provided XML document:
produces the wanted, correct result: