I am currently utilizing xslt for the transformation of xml to html. Below is an example of an .xml file.
<ImportOrganizationUtility-logging>
<log-session module-name="ImportOrganizationUtility" end="17:54:06" start="17:52:19">
<ou ou-name="Exchange" status="Success">
<Steps>
<step1 name="Add User" Username="hcimportuser3" PlanId="2" end="17:52:29" start="17:52:26" status="Success" > <log-description><![CDATA[
User added successfully.
]]></log-description> </step1>
<step2 name="ImportOrganization" end="17:53:35" start="17:52:29" status="Success" > <log-description><![CDATA[
Imported successfully.
]]></log-description></step2>
<step3 name="Segregation Utility Operations" MailDomain="exchange.com" end="17:53:58" start="17:53:36" status="Success">
<log-description><![CDATA[
Operation performed successfully.
]]></log-description>
</step3>
</Steps>
<log-description><![CDATA[Organization 'Exchange' imported successfully]]></log-description>
</ou>
<ou ou-name="APICall2" status="Failed">
<Steps>
<step1 name="Add User and Sell Plan" Username="hcimportuser3" PlanId="2" end="17:54:02" start="17:54:01" status="Success" />
<step2 name="ImportOrganization" end="17:54:06" start="17:54:02" status="Failed">
<log-description><![CDATA[Detailed error message.]]></log-description>
</step2>
</Steps>
<log-description><![CDATA[Detailed error message.]]></log-description>
</ou>
</log-session>
</ImportOrganizationUtility-logging>
I am in the process of creating two tables, where one is a sub table nested inside tr>td with style="display:none"
applied to it. Both tables are being generated correctly.
The issue I am encountering is related to a JavaScript function that I have created and attempted to call upon clicking on a parent table row to toggle the sub table, but it is not functioning as expected. Even after adding an alert, I am not receiving any alerts on row click, indicating that toggleRow()
is not being triggered.
If anyone can provide insights into what might be wrong here, I would greatly appreciate it. Below is an example of an .xsl file.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<style>
</style>
<header>
<link rel="stylesheet" type="text/css" href="bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="styles.css"/>
<script type="text/javascript">
function toggleRow(itemID){
alert(itemID);
if ((document.getElementById("tr" + itemID).style.display == 'none'))
{
document.getElementById("tr" + itemID).style.display = 'inline';
} else {
document.getElementById("tr" + itemID).style.display = 'none';
}
</script>
</header>
<body>
<div class="form-group">
<div class="table-responsive">
<table id="table" class="table table-striped moveabletable">
<thead>
<tr class="table100-head" >
<th class="medium col-sm-2" colspan="1" >Organization Name</th>
<!-- <th class="medium col-sm-2" ></th> -->
<th class="small col-sm-1">Owner Name</th>
<th class="small col-sm-1">Status</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<xsl:for-each select="ImportOrganizationUtility-logging/log-session/ou">
<xsl:sort select="@status" order="descending"/>
<xsl:variable name="i" select="position()"/>
<tr >
<xsl:attribute name="onclick">javascript:toggleRow(<xsl:value-of select="$i"/>)</xsl:attribute>
<td><i class="fa fa-plus-circle" aria-hidden="true"> </i> <xsl:value-of select="@ou-name"/>
<!-- <a onClick="toggleRow('{$i}')"> <xsl:value-of select="@ou-name"/></a> -->
</td>
<td><xsl:value-of select="Steps/step1/@Username"/></td>
<xsl:choose>
<xsl:when test="@status='Failed'">
<td style="color:red"><xsl:value-of select="@status"/></td>
</xsl:when>
<xsl:otherwise >
<td style="color:green"><xsl:value-of select="@status"/></td>
</xsl:otherwise>
</xsl:choose>
<td style="text-align:left"><xsl:value-of select="log-description"/></td>
</tr>
<tr id="tr{$i}" style="display:none">
<td colspan="4">
<table id="table" class="table table-striped moveabletable ">
<thead>
<tr class="table100-head" >
<th class="medium col-sm-2" colspan="1" >Step</th>
<th class="small col-sm-1">Status</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr >
<td>1</td>
<xsl:choose>
<xsl:when test="@status='Failed'">
<td style="color:red"><xsl:value-of select="Steps/step1/@status"/></td>
</xsl:when>
<xsl:otherwise >
<td style="color:green"><xsl:value-of select="Steps/step1/@status"/></td>
</xsl:otherwise>
</xsl:choose>
<td style="text-align:left"><xsl:value-of select="Steps/step1/log-description"/></td>
</tr>
<xsl:if test="Steps/step2/@status!=''">
<tr >
<td>2</td>
<xsl:choose>
<xsl:when test="@status='Failed'">
<td style="color:red"><xsl:value-of select="Steps/step2/@status"/></td>
</xsl:when>
<xsl:otherwise >
<td style="color:green"><xsl:value-of select="Steps/step2/@status"/></td>
</xsl:otherwise>
</xsl:choose>
<td style="text-align:left"><xsl:value-of select="Steps/step2/log-description"/></td>
</tr>
</xsl:if>
<xsl:if test="Steps/step3/@status!=''">
<tr >
<td>3</td>
<xsl:choose>
<xsl:when test="@status='Failed'">
<td style="color:red"><xsl:value-of select="Steps/step3/@status"/></td>
</xsl:when>
<xsl:otherwise >
<td style="color:green"><xsl:value-of select="Steps/step3/@status"/></td>
</xsl:otherwise>
</xsl:choose>
<td style="text-align:left"><xsl:value-of select="Steps/step3/log-description"/></td>
</tr>
</xsl:if>
</tbody>
</table>
</td>
</tr>
</xsl:for-each>
</tbody>
</table>
</div>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Above is a link to the image of the parent table https://i.stack.imgur.com/OMssP.png
Additionally, I aim to display the sub-table upon row click, similar to the illustration in this image https://i.stack.imgur.com/BMl9A.png
Your assistance in troubleshooting this matter would be highly valued. Thank you.