My goal is to compile multiple XML files into an HTML table and display the results. I utilize the xsl:elemnt
command to create individual cells within the tables as shown below:
<table>
<col span="1" class="firstCol" />
<thead align="center">
<tr class="headerColor" >
<th style="text-align: left" class="Test" >Test</th>
<th > Start </th>
<th > End </th>
<th > Duration </th>
</tr >
<tr style="border: 2px solid black" class="fristRow" onclick="CollapseExpandAll(this)" title="Click here to collapse/expand">
<td align="left">
<b>
<xsl:value-of select="attribute::name"/>
</b>
</td>
</tr>
</thead>
<xsl:element name="tableRows">
<xsl:attribute name="id">
<xsl:value-of select="attribute::name"/>
</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</table>
To enable expand/collapse functionality, I have implemented the following JavaScript code:
<script type="text/javascript" language="JavaScript" >
function CollapseExpandAll(obj)
{
var tableRows = obj.parentNode.parentNode.parentNode.getElementsByTagName("tableRows")[0];
var old = tableRows.style.display;
tableRows.style.display = (old == "none"?"":"none");
}
</script>
I am looking for help in modifying this script to simultaneously collapse or expand all created tables using a single button. Any guidance or assistance would be greatly appreciated. Thank you!
Update:
Below is a snippet of my XML file structure:
<SquishReport version="2.1" xmlns="http://www.froglogic.com/XML2">
<test name="tst_main">
<test name="tst_start_app">
<description> CDATA </description>
</test>
<test name="tst2">
<description> CDATA </description>
</test>
</test>
...
</SquishReport>
The desired outcome is to generate a separate table for each test_main
, resulting in three distinct tables within the HTML document.