I have some xslt script to parse the xml input and return the html file. So far it works fine. But now I need to parse the xml input to get this complex table with merging headers. What I want the output is below.
| V1 || V2 |
| version diff || version diff |
==========================================
| || |
| CONTENT || CONTENT |
| || |
As the Category1, Category2, Col 1, Col2, Col3, Col4 are all the table header. but Cateogry1, Cateogry2 are merged to make the table more clear.
My xml input like this,
<?xml version="1.0" encoding="utf-8"?>
<Index>
<entry name="Entry1">
<entry name="V1.baseversion">1.0.0.77</entry>
<entry name="V1.sizedifferencescount">0</entry>
<entry name="V2.sizedifferencescount">0</entry>
<entry name="V2.baseversion">1.0.0.75</entry>
</entry>
<entry name="Entry2">
<entry name="V1.baseversion">3.0.0.12</entry>
<entry name="V1.sizedifferencescount">0</entry>
<entry name="V2.sizedifferencescount">0</entry>
<entry name="V2.baseversion">3.0.0.13</entry>
</entry>
</Index>
Below is what I have tried the xslt so far, I intend to use this to parse the header.
<xsl:when test="position()=1">
<xsl:for-each select="*" >
<xsl:sort select="@name"/>
<xsl:if test=" ( (@name='V1.baseversion') or (@name='V1.sizedifferencescount') or (@name='V2.baseversion') or (@name='V2.sizedifferencescount'))">
<tr>
<th>
<xsl:attribute name="colspan">
<xsl:value-of select="2" />
</xsl:attribute>
<!--need to print Version 1 here-->
</th>
<th>
<xsl:attribute name="colspan">
<xsl:value-of select="2" />
</xsl:attribute>
<!--need to print Version 2 here-->
</th>
</tr>
<tr>
<th>
<!--need to print V1.baseversion here-->
</th>
<th>
<!--need to print V1.sizedifferencescount here-->
</th>
<th>
<!--need to print V2.baseversion here-->
</th>
<th>
<!--need to print V2.sizedifferencescount here-->
</th>
</tr>
</xsl:if>
</xsl:for-each>
</xsl:when>
And in the output html, each entry in the xml will be one row in the table. The output html should be like this.
<table>
<tr>
<th colspan=2>V1</th>
<th colspan=2>V2</th>
</tr>
<tr>
<th >Version</th>
<th >Diff</th>
<th >Version</th>
<th >Diff</th>
</tr>
<tr>
<td>XXXX</td><!--Display value for Entry1.V1.baseversion-->
<td>XXXX</td><!--Display value for Entry1.V1.sizedifferencescount-->
<td>XXXX</td><!--Display value for Entry1.V2.baseversion-->
<td>XXXX</td><!--Display value for Entry1.V2.sizedifferencescount-->
</tr>
<tr>
<td>XXXX</td><!--Display value for Entry2.V1.baseversion-->
<td>XXXX</td><!--Display value for Entry2.V1.sizedifferencescount-->
<td>XXXX</td><!--Display value for Entry2.V2.baseversion-->
<td>XXXX</td><!--Display value for Entry2.V2.sizedifferencescount-->
</tr>
</table>
Thank you for your information and help.
Alex