I am having the below input XML file:
Code:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<ConfigurationSetDataExtract>
<SOSData>
<OptionData>
<Option Name="KeyBoard" Value="Black"/>
<Option Name="Monitor" Value="15"/>
<Option Name="RAM" Value="8 GB"/>
</OptionData>
<VariantItem ItemID="000028"/>
</SOSData>
<SOSData>
<OptionData>
<Option Name="Controller Type" Value="Controller Type 1"/>
<Option Name="Spindle Type" Value="Single"/>
<Option Name="With Tailstock" Value="True"/>
</OptionData>
<VariantItem ItemID="000039"/>
</SOSData>
<SOSData>
<OptionData>
<Option Name="Controller Type" Value="Controller Type 1"/>
<Option Name="Spindle Type" Value="Single"/>
<Option Name="With Tailstock" Value="True"/>
</OptionData>
<VariantItem ItemID="000040"/>
</SOSData>
<SOSData>
<OptionData>
<Option Name="Controller Type" Value="Controller Type 1"/>
<Option Name="Spindle Type" Value="Single"/>
<Option Name="With Tailstock" Value="True"/>
</OptionData>
<VariantItem ItemID="000041"/>
</SOSData>
<SOSData>
<OptionData>
<Option Name="KeyBoard" Value="Black"/>
<Option Name="Monitor" Value="15"/>
<Option Name="RAM" Value="8 GB"/>
</OptionData>
<VariantItem ItemID="000029"/>
</SOSData>
</ConfigurationSetDataExtract>
Using xsl stylesheet (xslt version 1.0) I need to generate HTML Report file having the below format:
Code:
Sos Data Variant Items
Name Value
Controller Type Controller Type 1 000039
Spindle Type Single 000040
With Tailstock True 000041
Name Value
KeyBoard Black 000028
Monitor 15 000029
RAM 8 GB
Please note as shown in the input xml file the same element in may not be in order.
I have tried writing sample stylesheet, but it is this Grouping based on <OptionData> and < VariantItem> where I am stuck.
Here is my sample stylesheet:
Code:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:key name="ItemRevision" match="ItemRevision" use="@object_string_selected"/>
<xsl:template match="/">
<head>
<title>Configuration Set Report</title>
<script type="text/javascript">
<!-- function expcol(divId)
{
var div = document.getElementsByName(divId);
alert('welcome' + divId);
if (div.style.display=='none')
{
div.style.display = 'block';
}
else
{
div.style.display = 'none';
}
return true;
} -->
function toggleSibling()
{
if (window.event.srcElement.nextSibling.style.display=="none")
window.event.srcElement.nextSibling.style.display = "block";
else
window.event.srcElement.nextSibling.style.display = "none";
}
</script >
<style>
table
{
border-collapse: collapse;
border-spacing: 0pt;
width: 100%;
empty-cells: show;
border-color:#000000;
}
td
{
border-style:solid;
border-width:0.2pt;
border-color:#000000;
font-family: Arial, Helvetica, sans-serif;
}
th
{
border-style:solid;
border-width:0.2pt;
border-color:#000000;
background-color: #CCCCFF;
font-family: Arial, Helvetica, sans-serif;
}
<!-- Support for Foxfire browser requires specific class="sample" on all table elements -->
table.sample th
{
border-style:solid;
border-width: 1px 1px 1px 1px;
border-color: black black black black;
padding: 1px 1px 1px 1px;
background-color: #CCCCFF;
font-family: Arial, Helvetica, sans-serif;
}
table.sample tr
{
border-style:solid;
border-width: 1px 1px 1px 1px;
border-color: black black black black;
background-color: white;
font-family: Arial, Helvetica, sans-serif;
}
table.sample td
{
border-style: solid;
border-width: 1px 1px 1px 1px;
border-color: black black black black;
padding: 1px 1px 1px 1px;
background-color: white;
font-family: Arial, Helvetica, sans-serif;
}
.headings
{
background-color: #CCCCFF;
font-family: Arial, Helvetica, sans-serif;
}
</style>
</head>
<body BGCOLOR="#FFFFFF" link="#0000FF" vlink="#660066">
<br/>
<table class="sample">
<tr><!-- main table:row1::heading-->
<th>
<div align="left">
<img alt="Sample" src="C:\\Sample.jpg">
</img>
</div>
<div align="center">
<font size="+2">
Configuration Set Report
</font>
</div>
</th>
</tr>
<tr> <!-- Table for variant Items -->
<td>
<hr color="#000000"/>
<table> <!-- Selected Object Details -->
<tr align="center">
<th>SOS Data</th>
<th>Variant Items </th>
</tr>
<xsl:for-each select="ConfigurationSetDataExtract/SOSData">
<tr align="center">
<td>
<p>
<table>
<tr>
<th>Name</th>
<th>Value</th>
<xsl:for-each select="OptionData/Option">
<tr>
<td width="150px" align="center"><xsl:value-of select="@Name"/></td>
<td width="150px" align="center"><xsl:value-of select="@Value"/></td>
</tr>
</xsl:for-each>
</tr>
</table>
</p>
</td>
<td>
<xsl:for-each select="VariantItem">
<p>
<xsl:value-of select="@ItemID"/>
</p>
</xsl:for-each>
</td>
</tr>
</xsl:for-each>
</table>
</td>
</tr>
</table>
</body>
</xsl:template>
</xsl:stylesheet>