Adding alternate colors to a table - xslt

I have an asp.net web application. The application reads data from an xml. The xml has a reference to a xslt file which takes care of the table design and alignment. I add data to the xml in a dynamic manner.
I want every alternate row of the table to have a color (say grey) for readability. I believe it can be done in xslt itself using the line of code
<xsl:if test="(position() mod 2 = 0)">
Can someone please tell me how to do it? I have posted my xslt fully below.
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title>VPGate Media Mixer</title>
<meta http-equiv="expires" content="0"/>
<meta http-equiv="pragma" content="no-cache"/>
<meta http-equiv="cache-control" content="no-cache, must-revalidate"/>
<meta http-equiv="refresh" content="15"></meta>
<script src="/Common/common.js\" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="style001.css" />
<link rel="stylesheet" type="text/css" href="Grid.Default.css" />
</head>
<body class="WorkArea">
<div class="divSummaryHeader" id="SummaryHeader">
<h1>Media Mixer - VPGate</h1>
<xsl:for-each select="MMDiagnostics/Conference">
<h1>
Media Mixer - <xsl:value-of select="name"/>
</h1>
</xsl:for-each>
</div>
 
<div class="RadGrid RadGrid_Default" id="SummaryData" style="position:absolute;width:630px;overflow:auto">
<table border="0" class="rgMasterTable rgClipCells" cellspacing="0" cellpadding="0" >
<tr>
<input type="button" class="formEditBtn" id="SubBtn" value="Refresh" onclick="window.location=window.location;"/>
</tr>
<tr>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;" colspan="2">Conference</td>
</tr>
<tr>
<td>
<table border="0" class="rgMasterTable rgClipCells" cellspacing="0" cellpadding="0" >
<tr>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Conference Name</td>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Conference Id</td>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Composite Address</td>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Composite Port</td>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Composite Ssrc</td>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">No Of Participants</td>
</tr>
<xsl:for-each select="MediaMixer/Conference">
<!--<xsl:sort select="Name"/>-->
<xsl:if test="(position() mod 2 = 0)">
<tr class="rgAltRow SummaryTableDataRow">
<td valign = "top">
<xsl:value-of select="Name"/>
</td>
<td valign = "top">
<xsl:value-of select="ConfId"/>
</td>
<td valign = "top">
<xsl:value-of select="CompositeAddress"/>
</td>
<td valign = "top">
<xsl:value-of select="CompositePort"/>
</td>
<td valign = "top">
<xsl:value-of select="CompositeSsrc"/>
</td>
<td valign = "top">
<xsl:value-of select="NoOfParticipants"/>
</td>
</tr>
</xsl:if>
<xsl:if test="(position() mod 2 = 1)">
<td bgcolor="#aaaaff">
<tr class="rgAltRow SummaryTableDataRow">
<td valign = "top">
<xsl:value-of select="Name"/>
</td>
<td valign = "top">
<xsl:value-of select="ConfId"/>
</td>
<td valign = "top">
<xsl:value-of select="CompositeAddress"/>
</td>
<td valign = "top">
<xsl:value-of select="CompositePort"/>
</td>
<td valign = "top">
<xsl:value-of select="CompositeSsrc"/>
</td>
<td valign = "top">
<xsl:value-of select="NoOfParticipants"/>
</td>
</tr>
</td>
</xsl:if>
</xsl:for-each>
</table>
</td>
</tr>
</table>
 
<table border="0" class="rgMasterTable rgClipCells" cellspacing="1" cellpadding="1" >
<tr>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;" colspan="2">Participant</td>
</tr>
<tr>
<td>
<table border="0" class="rgMasterTable rgClipCells" cellspacing="0" cellpadding="0" >
<tr>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">ID 1</td>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">ID 2</td>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Participant Address</td>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Participant Listening Port</td>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">MM Listening Port</td>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">SSRC From Participant</td>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">SSRC From MM</td>
</tr>
<xsl:for-each select="MediaMixer/Conference/Participant">
<xsl:if test="(position() mod 2 = 0)">
<tr class="rgAltRow SummaryTableDataRow">
<td valign = "top">
<xsl:value-of select="ID1"/>
</td>
<td valign = "top">
<xsl:value-of select="ID2"/>
</td>
<td valign = "top">
<xsl:value-of select="ParticipantAddress"/>
</td>
<td valign = "top">
<xsl:value-of select="ParticipantListeningPort"/>
</td>
<td valign = "top">
<xsl:value-of select="MMListeningPort"/>
</td>
<td valign = "top">
<xsl:value-of select="SSRCFromParticipant"/>
</td>
<td valign = "top">
<xsl:value-of select="SSRCFromMM"/>
</td>
</tr>
</xsl:if>
<xsl:if test="(position() mod 2 = 1)">
<td bgcolor="#aaaaff">
<tr class="rgAltRow SummaryTableDataRow">
<td valign = "top">
<xsl:value-of select="ID1"/>
</td>
<td valign = "top">
<xsl:value-of select="ID2"/>
</td>
<td valign = "top">
<xsl:value-of select="ParticipantAddress"/>
</td>
<td valign = "top">
<xsl:value-of select="ParticipantListeningPort"/>
</td>
<td valign = "top">
<xsl:value-of select="MMListeningPort"/>
</td>
<td valign = "top">
<xsl:value-of select="SSRCFromParticipant"/>
</td>
<td valign = "top">
<xsl:value-of select="SSRCFromMM"/>
</td>
</tr>
</td>
</xsl:if>
</xsl:for-each>
</table>
</td>
</tr>
</table>
 
<div style="display:none">
<iframe id="frameUpdate" name="frameUpdate" width="100%"></iframe>
</div>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

You're actually on the right track. Assign numbered css classes and use position() mod 2 to compute which css class to call.
Here's a demonstration:
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output version="1.0" encoding="utf-8" indent="yes" method="html"/>
<xsl:template match="/">
<xsl:variable name="sortValue">title</xsl:variable>
<style type="text/css">
.row0 { background-color: blue; }
.row1 { background-color: red; }
</style>
<table border='1'>
<tr>
<th>ID</th>
<th>Artist</th>
<th>Title</th>
<th>Album</th>
<th>Length</th>
</tr>
<xsl:for-each select="*/song">
<xsl:variable name="rowClass">
row <xsl:number value="position() mod 2"/>
</xsl:variable>
<tr>
<td class="{$rowClass}"><xsl:value-of select="./#id"/></td>
<td class="{$rowClass}"><xsl:value-of select="./artist"/></td>
<td class="{$rowClass}"><xsl:value-of select="./title"/></td>
<td class="{$rowClass}"><xsl:value-of select="./album"/></td>
<td class="{$rowClass}"><xsl:value-of select="./length"/></td>
</tr>
</xsl:for-each>
</table>
HTH.

Related

XML in a XSLT-Stlesheet tabel

I have a problem. I made a table in a xslt stylesheet. Now I don't know how to put only one Unit-node in the upper table and then all the funktion nodes under that. For the second, third... Unit-node I want both tables under that.
example in a picture in my dropbox (I have not enough point on stckoverflow)
https://www.dropbox.com/s/jfzii4ytllfb6m9/Mappe1.pdf?dl=0
<?xml version="1.0" encoding="UTF-8"?>
<PLC_LOG>
<HostName>DERTLP0350</HostName>
<Unit>
<Line>123456</Line>
<Funktion>
<sName>CounterDown1</sName>
<sDescription>automatic</sDescription>
<tMaxExecutionTime>T#3s</tMaxExecutionTime>
<Timestamp>2014-12-15-14:11:10.298</Timestamp>
<Line>12345678</Line>
<bFinish>TRUE</bFinish>
<bResult>TRUE</bResult>
</Funktion><sName>CounterDown</sName>
<sDescription>Test of the CounterDown</sDescription>
<tMaxExecutionTime>T#15s</tMaxExecutionTime>
<bFinish>TRUE</bFinish>
<bResult>FALSE</bResult>
<Timestamp>2014-12-15-14:11:11.179</Timestamp>
</Unit>
<Unit>
<Line>123456</Line>
<Funktion>
<sName>CounterDown1</sName>
<sDescription>automatic</sDescription>
<tMaxExecutionTime>T#3s</tMaxExecutionTime>
<Timestamp>2014-12-15-14:11:10.298</Timestamp>
<Line>12345678</Line>
<bFinish>TRUE</bFinish>
<bResult>FALSE</bResult>
</Funktion><sName>CounterDown</sName>
<sDescription>Test of the CounterDown</sDescription>
<tMaxExecutionTime>T#15s</tMaxExecutionTime>
<bFinish>TRUE</bFinish>
<bResult>FALSE</bResult>
<Timestamp>2014-12-15-14:11:11.179</Timestamp>
</Unit>
</PLC_LOG>
My made my table with this code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match = "/">
<html>
<head>
<title>Automated Test of the System</title>
<style type="text/css">
h1 {color: #000000}
h2 {color: #000000}
</style>
</head>
<body bgcolor="white">
<h1 >
<a name="Content">Testreport PLC</a>
</h1>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="PLC_LOG">
<table border="1">
<thead>
<tr bgcolor="#BDBDBD">
<th width="650" align="center">HostName</th>
<th width="650" align="center">Link to Configuration</th>
</tr>
</thead>
<tbody>
<xsl:for-each select="/PLC_LOG">
<tr>
<td align="center">
<xsl:value-of select="HostName"/>
</td>
<td align="center">
<xsl:value-of select="HostName"/>
</td>
</tr>
</xsl:for-each>
</tbody>
</table>
<table border="1">
<thead>
<tr bgcolor="#0070C0">
<th colspan="7">TestUNIT</th>
</tr>
<tr bgcolor="#0070C0">
<th width="200" align="center">Name</th>
<th width="325" align="center">Description</th>
<th width="325" align="center">Message</th>
<th width="100" align="center">MaxExecutionTime</th>
<th width="150" align="center">Timestamp</th>
<th width="100" align="center">TestFinish</th>
<th width="100" align="center">Result</th>
</tr>
</thead>
<tbody>
<xsl:for-each select="/*/Unit">
<tr>
<td>
<xsl:value-of select="sName"/>
</td>
<td>
<xsl:value-of select="sDescription"/>
</td>
<td>
<xsl:for-each select="node()[starts-with(name(), 'Line')]">
<xsl:value-of select="."/>
</xsl:for-each>
</td>
<td align="center">
<xsl:value-of select="tMaxExecutionTime"/>
</td>
<td>
<xsl:value-of select="Timestamp"/>
</td>
<xsl:choose>
<xsl:when test="bFinish='TURE'">
<td bgcolor="#00FF00" align="center">
<b>Passed</b>
</td>
</xsl:when>
<xsl:when test="bFinish='TRUE'">
<td bgcolor="red" align="center">
<b>Failed</b>
</td>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="bResult='TRUE'">
<td bgcolor="#00FF00" align="center">
<b>Passed</b>
</td>
</xsl:when>
<xsl:when test="bResult='FALSE'">
<td bgcolor="red" align="center">
<b>Failed</b>
</td>
</xsl:when>
</xsl:choose>
</tr>
</xsl:for-each>
</tbody>
</table>
<table border="1">
<thead>
<tr bgcolor="#0099ff">
<th colspan="7">TestFunktion</th>
</tr>
<tr bgcolor="#0099ff">
<th width="200" align="center">Name</th>
<th width="325" align="center">Description</th>
<th width="325" align="center">Message</th>
<th width="100" align="center">MaxExecutionTime</th>
<th width="150" align="center">Timestamp</th>
<th width="100" align="center">TestFinish</th>
<th width="100" align="center">Result</th>
</tr>
</thead>
<tbody>
<xsl:for-each select="/*/*/Funktion">
<tr>
<td>
<xsl:value-of select="sName"/>
</td>
<td>
<xsl:value-of select="sDescription"/>
</td>
<td>
<xsl:for-each select="node()[starts-with(name(), 'Line')]">
<xsl:value-of select="."/>
</xsl:for-each>
</td>
<td align="center">
<xsl:value-of select="tMaxExecutionTime"/>
</td>
<td>
<xsl:value-of select="Timestamp"/>
</td>
<xsl:choose>
<xsl:when test="bFinish='TRUE'">
<td bgcolor="#00FF00" align="center">
<b>Passed</b>
</td>
</xsl:when>
<xsl:when test="bFinish='FALSE'">
<td bgcolor="red" align="center">
<b>Failed</b>
</td>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="bResult='TRUE'">
<td bgcolor="#00FF00" align="center">
<b>Passed</b>
</td>
</xsl:when>
<xsl:when test="bResult='FALSE'">
<td bgcolor="red" align="center">
<b>Failed</b>
</td>
</xsl:when>
</xsl:choose>
</tr>
</xsl:for-each>
</tbody>
</table>
<br></br>
<br></br>
</xsl:template>
</xsl:stylesheet>
Thanks for help!!!!
This is very confusing, esp. since the picture does not seem to match the example input. I would suggest you concentrate first on getting the structure right. Try the following as your starting point:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates select="PLC_LOG/Unit"/>
</body>
</html>
</xsl:template>
<xsl:template match="Unit">
<table border="1">
<thead>
<tr>
<th colspan="7">TestUNIT</th>
</tr>
<tr>
<th>Name</th>
<th>Description</th>
<th>Message</th>
<th>MaxExecutionTime</th>
<th>Timestamp</th>
<th>TestFinish</th>
<th>Result</th>
</tr>
<tr>
<td><xsl:value-of select="sName"/></td>
<td><xsl:value-of select="sDescription"/></td>
<td><xsl:value-of select="Line"/></td>
<td><xsl:value-of select="tMaxExecutionTime"/></td>
<td><xsl:value-of select="Timestamp"/></td>
<td><xsl:value-of select="bFinish"/></td>
<td><xsl:value-of select="bResult"/></td>
</tr>
</thead>
<tbody>
<tr>
<th colspan="7">TestFunktion</th>
</tr>
<tr>
<xsl:for-each select="Funktion[1]/*">
<th><xsl:value-of select="local-name()"/></th>
</xsl:for-each>
</tr>
<xsl:apply-templates select="Funktion"/>
</tbody>
</table>
</xsl:template>
<xsl:template match="Funktion">
<tr>
<xsl:for-each select="*">
<td><xsl:value-of select="."/></td>
</xsl:for-each>
</tr>
</xsl:template>
</xsl:stylesheet>
Once you have the table structure and contents the way you want them, add CSS styling as necessary.

duplication in xslt preceeding-sibling

i've the below xml document.
<toc-div>
<toc-item>
<toc-title>CHAPTER 1 INTRODUCTION</toc-title>
<toc-subitem num="1.">
<toc-title>The British Virgin Islands</toc-title>
<toc-pg>1.001</toc-pg>
</toc-subitem>
<toc-subitem num="2.">
<toc-title>History and early constitutional developments</toc-title>
<toc-pg>1.003</toc-pg>
</toc-subitem>
<toc-subitem num="3.">
<toc-title>Development as a financial centre</toc-title>
<toc-pg>1.008</toc-pg>
</toc-subitem>
<toc-subitem num="4.">
<toc-title>Common Law and Equity</toc-title>
<toc-pg>1.015</toc-pg>
</toc-subitem>
<toc-subitem num="5.">
<toc-title>Statutes</toc-title>
<toc-pg>1.017</toc-pg>
</toc-subitem>
<toc-subitem num="6.">
<toc-title>Taxation</toc-title>
<toc-pg>1.022</toc-pg>
</toc-subitem>
</toc-item>
and i'm applying the below xslt.
<xsl:template match="toc-subitem">
<table>
<td>
<xsl:value-of select="preceding-sibling::toc-title[1]"/>
</td></table>
<xsl:variable name="tocpg">
<xsl:value-of select="current()/toc-pg"/></xsl:variable>
<xsl:variable name="abc">
<xsl:choose>
<xsl:when test="not(contains(#num, '('))">
<xsl:value-of select="1"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="2"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="before">
<xsl:value-of select="normalize-space(substring-before($tocpg, '.'))"/>
</xsl:variable>
<xsl:variable name="after">
<xsl:value-of select="normalize-space(substring-after($tocpg, '.'))"/>
</xsl:variable>
<xsl:variable name="z">
<xsl:value-of select="current()/#num"/>
</xsl:variable>
<xsl:variable name="tocpgtag" select="translate($tocpg,'.', '-')"/>
<xsl:variable name="numa" select="number(translate(#num, '.', ''))" />
<xsl:variable name="itemlevel">
<xsl:value-of select="$ThisDocument//ntw:nums[#num=$abc]/#word"/>
</xsl:variable>
<xsl:variable name="tocitemlevel">
<xsl:value-of select="concat('toc-item-', $itemlevel,'-level')"/>
</xsl:variable>
<xsl:variable name="conc">
<xsl:value-of select="concat('er:#BVI_CH_0',$before, '/P', normalize-space($tocpgtag))"/>
</xsl:variable>
<table class="{$tocitemlevel}">
<tbody>
<tr>
<td class="toc-subitem-num">
<xsl:value-of select="$z" />
</td>
<td class="toc-title">
<xsl:value-of select="current()/toc-title" />
</td>
<td class="toc-pg">
<a href="{$conc}">
<xsl:value-of select="current()/toc-pg" />
</a>
</td>
</tr>
</tbody>
</table>
</xsl:template>
when i'm applying this template, the output i'm getting is as below.
<table>
<td>CHAPTER 1 INTRODUCTION</td>
</table>
<table class="toc-item--level">
<tbody>
<tr>
<td class="toc-subitem-num">1.</td>
<td class="toc-title">The British Virgin Islands</td>
<td class="toc-pg">1.001</td>
</tr>
</tbody>
</table>
<table>
<td>CHAPTER 1 INTRODUCTION</td>
</table>
<table class="toc-item--level">
<tbody>
<tr>
<td class="toc-subitem-num">2.</td>
<td class="toc-title">History and early constitutional developments</td>
<td class="toc-pg">1.003</td>
</tr>
</tbody>
</table>
<table>
<td>CHAPTER 1 INTRODUCTION</td>
</table>
<table class="toc-item--level">
<tbody>
<tr>
<td class="toc-subitem-num">3.</td>
<td class="toc-title">Development as a financial centre</td>
<td class="toc-pg">1.008</td>
</tr>
</tbody>
</table>
<table>
<td>CHAPTER 1 INTRODUCTION</td>
</table>
<table class="toc-item--level">
<tbody>
<tr>
<td class="toc-subitem-num">4.</td>
<td class="toc-title">Common Law and Equity</td>
<td class="toc-pg">1.015</td>
</tr>
</tbody>
</table>
<table>
<td>CHAPTER 1 INTRODUCTION</td>
</table>
<table class="toc-item--level">
<tbody>
<tr>
<td class="toc-subitem-num">5.</td>
<td class="toc-title">Statutes</td>
<td class="toc-pg">1.017</td>
</tr>
</tbody>
</table>
<table>
<td>CHAPTER 1 INTRODUCTION</td>
</table>
<table class="toc-item--level">
<tbody>
<tr>
<td class="toc-subitem-num">6.</td>
<td class="toc-title">Taxation</td>
<td class="toc-pg">1.022</td>
</tr>
</tbody>
</table>
but i want to get it as below
<table>
<td>CHAPTER 1 INTRODUCTION</td>
</table>
<table class="toc-item--level">
<tbody>
<tr>
<td class="toc-subitem-num">1.</td>
<td class="toc-title">The British Virgin Islands</td>
<td class="toc-pg">1.001</td>
</tr>
</tbody>
</table>
<table class="toc-item--level">
<tbody>
<tr>
<td class="toc-subitem-num">2.</td>
<td class="toc-title">History and early constitutional developments</td>
<td class="toc-pg">1.003</td>
</tr>
</tbody>
</table>
<table class="toc-item--level">
<tbody>
<tr>
<td class="toc-subitem-num">3.</td>
<td class="toc-title">Development as a financial centre</td>
<td class="toc-pg">1.008</td>
</tr>
</tbody>
</table>
<table class="toc-item--level">
<tbody>
<tr>
<td class="toc-subitem-num">4.</td>
<td class="toc-title">Common Law and Equity</td>
<td class="toc-pg">1.015</td>
</tr>
</tbody>
</table>
<table class="toc-item--level">
<tbody>
<tr>
<td class="toc-subitem-num">5.</td>
<td class="toc-title">Statutes</td>
<td class="toc-pg">1.017</td>
</tr>
</tbody>
</table>
<table class="toc-item--level">
<tbody>
<tr>
<td class="toc-subitem-num">6.</td>
<td class="toc-title">Taxation</td>
<td class="toc-pg">1.022</td>
</tr>
</tbody>
</table>
please let me know where I'm going wrong.
Thanks
Note:
Your title table is not valid - it does not have <tr>.
The reason your XSLT gave you duplicate toc-title was that you printed it for every toc-subitem processed. In the solution below it is printed only once.
Make the following change to your XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
<xsl:template match="//toc-item">
<table>
<td>
<!-- Print the title *once* -->
<xsl:value-of select="./toc-title"/>
</td>
</table>
<!-- Process each subitem -->
<xsl:apply-templates select="toc-subitem"/>
</xsl:template>
<xsl:template match="toc-subitem">
<!-- Removed the <table> with the preceding sibling -->
<xsl:variable name="tocpg">
<xsl:value-of select="current()/toc-pg"/></xsl:variable>
<!-- Put the rest of your XSLT here, no changes there -->
</xsl:template>
</xsl:stylesheet>
You should use separate templates for this (I also cleaned up a bunch of the <xsl:variable>s):
<xsl:template match="toc-title">
<table>
<tr>
<td>
<xsl:value-of select="preceding-sibling::toc-title[1]"/>
</td>
</tr>
</table>
</xsl:template>
<xsl:template match="toc-subitem">
<xsl:variable name="tocpg" select="toc-pg" />
<xsl:variable name="abc" select="1 + contains(#num, '(')" />
<xsl:variable name="before"
select="normalize-space(substring-before($tocpg, '.'))"/>
<xsl:variable name="after"
select="normalize-space(substring-after($tocpg, '.'))"/>
<xsl:variable name="z" select="#num"/>
<xsl:variable name="tocpgtag" select="translate($tocpg,'.', '-')"/>
<xsl:variable name="numa" select="number(translate(#num, '.', ''))" />
<xsl:variable name="itemlevel"
select="$ThisDocument//ntw:nums[#num=$abc]/#word"/>
<xsl:variable name="tocitemlevel"
select="concat('toc-item-', $itemlevel,'-level')"/>
<xsl:variable name="conc"
select="concat('er:#BVI_CH_0',$before, '/P',
normalize-space($tocpgtag))"/>
<table class="{$tocitemlevel}">
<tbody>
<tr>
<td class="toc-subitem-num">
<xsl:value-of select="$z" />
</td>
<td class="toc-title">
<xsl:value-of select="toc-title" />
</td>
<td class="toc-pg">
<a href="{$conc}">
<xsl:value-of select="toc-pg" />
</a>
</td>
</tr>
</tbody>
</table>
</xsl:template>
However, I think putting every row in its own table is not a very good design. Why have you chosen to do that?
I don't really understand why you'd want output like that (<td> is not a valid child of <table>, for example, in HTML), but this stylesheet should get you closer (I rewrote the stylesheet to split your code into separate <xsl:template> elements):
Stylesheet
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8" indent="yes"/>
<xsl:template match="/">
<html>
<body>
<table>
<xsl:apply-templates/>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="toc-item/toc-title">
<td><xsl:value-of select="."/></td>
</xsl:template>
<xsl:template match="toc-subitem">
<!--
I don't know how your code that fetches the TOC item level is supposed
to work so you'll have to figure that out yourself.
-->
<table class="toc-item-$level-level">
<tbody>
<tr>
<xsl:apply-templates select="#* | node()"/>
</tr>
</tbody>
</table>
</xsl:template>
<xsl:template match="#num">
<td class="toc-subitem-num">
<xsl:value-of select="."/>
</td>
</xsl:template>
<xsl:template match="toc-subitem/toc-title">
<td class="toc-title">
<xsl:value-of select="."/>
</td>
</xsl:template>
<xsl:template match="toc-pg">
<td class="toc-pg">
<a href="{concat('er:#BVI_CH_0', substring-before(., '.'), '/P', translate(., '.', '-'))}">
<xsl:value-of select="."/>
</a>
</td>
</xsl:template>
</xsl:stylesheet>
Input
<?xml version="1.0"?>
<toc-div>
<toc-item>
<toc-title>CHAPTER 1 INTRODUCTION</toc-title>
<toc-subitem num="1.">
<toc-title>The British Virgin Islands</toc-title>
<toc-pg>1.001</toc-pg>
</toc-subitem>
<toc-subitem num="2.">
<toc-title>History and early constitutional developments</toc-title>
<toc-pg>1.003</toc-pg>
</toc-subitem>
<toc-subitem num="3.">
<toc-title>Development as a financial centre</toc-title>
<toc-pg>1.008</toc-pg>
</toc-subitem>
<toc-subitem num="4.">
<toc-title>Common Law and Equity</toc-title>
<toc-pg>1.015</toc-pg>
</toc-subitem>
<toc-subitem num="5.">
<toc-title>Statutes</toc-title>
<toc-pg>1.017</toc-pg>
</toc-subitem>
<toc-subitem num="6.">
<toc-title>Taxation</toc-title>
<toc-pg>1.022</toc-pg>
</toc-subitem>
</toc-item>
</toc-div>
Output
<html>
<body>
<table>
<td>CHAPTER 1 INTRODUCTION</td>
<table class="toc-item-$level-level">
<tbody>
<tr>
<td class="toc-subitem-num">1.</td>
<td class="toc-title">The British Virgin Islands</td>
<td class="toc-pg">
1.001
</td>
</tr>
</tbody>
</table>
<table class="toc-item-$level-level">
<tbody>
<tr>
<td class="toc-subitem-num">2.</td>
<td class="toc-title">History and early constitutional developments</td>
<td class="toc-pg">
1.003
</td>
</tr>
</tbody>
</table>
<table class="toc-item-$level-level">
<tbody>
<tr>
<td class="toc-subitem-num">3.</td>
<td class="toc-title">Development as a financial centre</td>
<td class="toc-pg">
1.008
</td>
</tr>
</tbody>
</table>
<table class="toc-item-$level-level">
<tbody>
<tr>
<td class="toc-subitem-num">4.</td>
<td class="toc-title">Common Law and Equity</td>
<td class="toc-pg">
1.015
</td>
</tr>
</tbody>
</table>
<table class="toc-item-$level-level">
<tbody>
<tr>
<td class="toc-subitem-num">5.</td>
<td class="toc-title">Statutes</td>
<td class="toc-pg">
1.017
</td>
</tr>
</tbody>
</table>
<table class="toc-item-$level-level">
<tbody>
<tr>
<td class="toc-subitem-num">6.</td>
<td class="toc-title">Taxation</td>
<td class="toc-pg">
1.022
</td>
</tr>
</tbody>
</table>
</table>
</body>
</html>
Just remove the <html> and <body> elements from the first <xsl:template> rule if you really don't need them.

XSLT Dynamic Rows

I'm having an issue with the data being properly formatted. The top level node is Part. The elements below the node are AML and Documents. The AML and Documents can be different values. AML can be greater than Documents and Documents can be greater then AML. I need the elements for Documents and AML to be on the same row, so that the table is properly formatted. Please let me know if you need anymore information and thank you for your help its greatly appreciated.
Data
<Item type="Part">
<item_number>E008643</item_number>
<Relationships>
<Item type="Part AML">
<related_id keyed_name="0000-009" type="Manufacturer Part">
<Item type="Manufacturer Part">
<manufacturer keyed_name="Fasteners Co." type="Manufacturer"></manufacturer>
<item_number>0000-009</item_number>
</Item>
</related_id>
<state>Preliminary</state>
</Item>
<Item type="Part AML">
<related_id keyed_name="1234" type="Manufacturer Part">
<Item type="Manufacturer Part">
<id keyed_name="1234" type="Manufacturer Part"></id>
<manufacturer keyed_name="Vishay/Dale" type="Manufacturer"></manufacturer>
<item_number>1234</item_number>
</Item>
</related_id>
<state>Preliminary</state>
</Item>
<Item type="Part Document">
<related_id keyed_name="D000006" type="Document">
<Item type="Document">
<id keyed_name="D000006" type="Document"></id>
<major_rev>B</major_rev>
<name>Hardware Doc</name>
<item_number>D000006</item_number>
</Item>
</related_id>
</Item>
<Item type="Part Document">
<related_id keyed_name="D000005" type="Document">
<Item type="Document">
<major_rev>B</major_rev>
<name>Firmware</name>
<item_number>D000005</item_number>
</Item>
</related_id>
</Item>
<Item type="Part Document">
<related_id keyed_name="D000003" type="Document">
<Item type="Document">
<major_rev>A</major_rev>
<name>Design Spec</name>
<item_number>D000003</item_number>
</Item>
</related_id>
</Item>
<Item type="Part BOM">
<related_id keyed_name="E000371" type="Part">
<Item type="Part">
<item_number>E000371</item_number>
<Relationships>
<Item type="Part AML">
<related_id keyed_name="3Z1JTTD" type="Manufacturer Part">
<Item type="Manufacturer Part">
<manufacturer keyed_name="Speer" type="Manufacturer"></manufacturer>
<item_number>3Z1JTTD</item_number>
</Item>
</related_id>
<state>Preliminary</state>
</Item>
<Item type="Part AML">
<related_id keyed_name="000T" type="Manufacturer Part">
<Item type="Manufacturer Part">
<manufacturer keyed_name="Nickel" type="Manufacturer"></manufacturer>
<item_number>000T</item_number>
</Item>
</related_id>
<source_id keyed_name="E000371" type="Part"></source_id>
<state>Preliminary</state>
</Item>
<Item type="Part AML">
<related_id keyed_name="R00V" type="Manufacturer Part">
<Item type="Manufacturer Part">
<manufacturer keyed_name="Sonic" type="Manufacturer"></manufacturer>
<item_number>R00V</item_number>
</Item>
</related_id>
<state>Preliminary</state>
</Item>
<Item type="Part AML">
<related_id keyed_name="TRF" type="Manufacturer Part">
<Item type="Manufacturer Part">
<manufacturer keyed_name="Components" type="Manufacturer"></manufacturer>
<item_number>TRF</item_number>
</Item>
</related_id>
<state>Preliminary</state>
</Item>
<Item type="Part AML">
<related_id keyed_name="70RL" type="Manufacturer Part">
<Item type="Manufacturer Part">
<manufacturer keyed_name="Comp" type="Manufacturer"></manufacturer>
<item_number>70RL</item_number>
</Item>
</related_id>
<state>Preliminary</state>
</Item>
<Item type="Part Document">
<related_id keyed_name="D000007" type="Document">
<Item type="Document">
<major_rev>B</major_rev>
<name>BOX</name>
<item_number>D000007</item_number>
</Item>
</related_id>
<state is_null="1" />
</Item>
<Item type="Part Document">
<related_id keyed_name="D000008" type="Document">
<Item type="Document">
<major_rev>A</major_rev>
<name>SOCKET</name>
<item_number>D000008</item_number>
</Item>
</related_id>
<state is_null="1" />
</Item>
</Relationships>
</Item>
</related_id>
</Item>
</Relationships>
Style Sheet
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:aras="http://www.aras-corp.com" exclude-result-prefixes="msxsl">
<xsl:output method="html" omit-xml-declaration="yes" standalone="yes" indent="yes"></xsl:output>
<xsl:template match="/">
<html>
<head></head>
<style type="text/css" userData="Global">
table {empty-cells:show; border-collapse:collapse;}
th {font-family:helvetica; font-size:8pt; padding:2px; border:1px #000000 solid; background-color:#CCCCCC; text-transform:capitalize;}
td {font-family:helvetica; font-size:8pt; padding:2px; border:1px #000000 solid;}
td.noBorder {font-family:helvetica; font-size:8pt; padding:2px; border-width:0;}
</style>
<body topmargin="50" leftmargin="50">
<table border="0" cellspacing="0" cellpadding="0" width="1850">
<tr valign="top">
<td class="noBorder" align="left" colspan="9" uniqueID="ms__id39">
</td>
</tr>
<tr valign="bottom">
<td class="noBorder" colspan="13" style="font-family:helvetica;font-size:15pt;color:#DA1943;padding:2px;" align="left" uniqueID="ms__id22">Bill of Materials Report - <xsl:value-of select="//Item/name"></xsl:value-of> Rev <xsl:value-of select="//Item/major_rev"></xsl:value-of>
</td>
<td class="noBorder" colspan="7" style="font-family:helvetica;font-size:10pt;padding:2px;" align="right" uniqueID="ms__id23">Generated on: <script>function m00(r, n){r += ""; if (!n) n = 2; while(r.length < n){r = "0" + r;} return r;} var dt = new Date(); var a = top.opener.top.aras; if (a){var s = m00(dt.getUTCFullYear(),4)+"-"+m00((dt.getUTCMonth()+1))+"-"+m00(dt.getUTCDate())+"T"+m00(dt.getUTCHours())+":"+m00(dt.getUTCMinutes())+":"+m00(dt.getUTCSeconds())+"+0000"; s = a.convertToNeutral(s, "date", "yyyy-MM-ddTHH:mm:sszzz"); s = a.convertFromNeutral(s, "date", "short_date"); document.write(s);}</script>
</td>
</tr>
<tr>
<th>Part Number</th>
<th>Manufacturer</th>
<th>Manufacturer Part</th>
<th>Document Number</th>
<th>Document Name</th>
<th>Document Rev</th>
</tr>
<xsl:apply-templates select="//Item[#type='Part']"></xsl:apply-templates>
</table>
</body>
<script src="../../javascript/PopupMenu.js"></script>
<script src="../../javascript/PopupMenu.js"></script>
<script src="../../javascript/PopupMenu.js"></script>
<script src="../../javascript/PopupMenu.js"></script>
</html>
</xsl:template>
<xsl:template match="Item[#type='Part']">
<!-- Find the number Row Span -->
<xsl:variable name="AML">
<xsl:choose>
<xsl:when test="count(Relationships/Item[#type='Part AML'])=0">1</xsl:when>
<xsl:otherwise>
<xsl:value-of select="count(Relationships/Item[#type='Part AML'])"></xsl:value-of>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="Doc">
<xsl:choose>
<xsl:when test="count(Relationships/Item[#type='Part Document'])=0">1</xsl:when>
<xsl:otherwise>
<xsl:value-of select="count(Relationships/Item[#type='Part Document'])"></xsl:value-of>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="rowCount">
<xsl:choose>
<xsl:when test="$AML < $Doc"><xsl:value-of select="$Doc"></xsl:value-of></xsl:when>
<xsl:otherwise>
<xsl:value-of select="$AML"></xsl:value-of>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Grab values -->
<tr>
<td rowspan="{$rowCount}" width="5%" align="center" uniqueID="ms__id16">
<xsl:value-of select="item_number"></xsl:value-of>
</td>
<td width="13%" align="center" uniqueID="ms__id26">
<xsl:value-of select="Relationships/Item[#type='Part AML'][1]/related_id/Item/manufacturer/#keyed_name"></xsl:value-of>
</td>
<td width="13%" align="center" uniqueID="ms__id27">
<xsl:value-of select="Relationships/Item[#type='Part AML'][1]/related_id/Item/item_number"></xsl:value-of>
</td>
<td width="5%" align="center" uniqueID="ms__id28">
<xsl:value-of select="Relationships/Item[#type='Part Document'][1]/related_id/Item/item_number"></xsl:value-of>
</td>
<td width="13%px" align="center" uniqueID="ms__id29">
<xsl:value-of select="Relationships/Item[#type='Part Document'][1]/related_id/Item/name"></xsl:value-of>
</td>
<td width="8%" align="center" uniqueID="ms__id30">
<xsl:value-of select="Relationships/Item[#type='Part Document'][1]/related_id/Item/major_rev"></xsl:value-of>
</td>
<td rowspan="{$rowCount}" width="8%" align="center" uniqueID="ms__id37">
<xsl:value-of select="count(Relationships/Item[#type='Part AML'])"></xsl:value-of>
</td>
<td rowspan="{$rowCount}" width="8%" align="center" uniqueID="ms__id38">
<xsl:value-of select="count(Relationships/Item[#type='Part Document'])"></xsl:value-of>
</td>
<td rowspan="{$rowCount}" width="8%" align="center" uniqueID="ms__id40">
<xsl:value-of select="position() mod 2 = 1"></xsl:value-of>
</td>
</tr>
<!-- Assing first row for AML and Doc -->
<xsl:apply-templates select="Relationships/Item[#type='Part AML'][position()!=1]|Relationships/Item[#type='Part Document'][position()!=1]"></xsl:apply-templates>
</xsl:template>
<!-- AML and Doc Rows 2+ -->
<xsl:template match="text()" />
<xsl:template match="Item[#type = 'Part AML'][not(following-sibling::Item[1]/#type = 'Part Document')]">
<xsl:call-template name="ItemRow">
<xsl:with-param name="AmlItem" select="." />
</xsl:call-template>
</xsl:template>
<xsl:template match="Item[#type='Part Document']">
<xsl:variable name="lastItem" select="preceding-sibling::Item[1][#type = 'Part AML']" />
<xsl:call-template name="ItemRow">
<xsl:with-param name="AmlItem" select="$lastItem" />
<xsl:with-param name="PartDocument" select="." />
</xsl:call-template>
</xsl:template>
<xsl:template name="ItemRow">
<xsl:param name="AmlItem" />
<xsl:param name="PartDocument" select="_" />
<xsl:variable name="rowData">
<row value="{$AmlItem/related_id/Item/manufacturer/#keyed_name}" id="32" />
<row value="{$AmlItem/related_id/Item[#type='Manufacturer Part']/item_number}" id="33" />
<row value="{$PartDocument/related_id[#type='Document']/Item/item_number}" id="34" />
<row value="{$PartDocument/related_id[#type='Document']/Item/name}" id="35" />
<row value="{$PartDocument/related_id[#type='Document']/Item/major_rev}" id="36" />
</xsl:variable>
<tr>
<xsl:for-each select="msxsl:node-set($rowData)/row">
<td width="13%" align="center" uniqueID="ms__id{#id}">
<xsl:value-of select="#value"/>
</td>
</xsl:for-each>
</tr>
</xsl:template>
</xsl:stylesheet>
Output 1-7-12
<td width="13%" align="center" uniqueID="ms__id32">Bobs Workshop</td>
<td width="13%" align="center" uniqueID="ms__id33">1234</td>
<td width="13%" align="center" uniqueID="ms__id34">D000005</td>
<td width="13%" align="center" uniqueID="ms__id35">Firmware</td>
<td width="13%" align="center" uniqueID="ms__id36">B</td>
<td width="13%" align="center" uniqueID="ms__id34">D000003</td>
<td width="13%" align="center" uniqueID="ms__id35">Design Spec</td>
<td width="13%" align="center" uniqueID="ms__id36">A</td>
Desired Output
<!-- If both present -->
<tr>
<td width="13%" align="center" uniqueID="ms__id32">Bobs Workshop</td>
<td width="13%" align="center" uniqueID="ms__id33">1234</td>
<td width="13%" align="center" uniqueID="ms__id34">D000005</td>
<td width="13%" align="center" uniqueID="ms__id35">Firmware</td>
<td width="13%" align="center" uniqueID="ms__id36">B</td>
</tr>
<!-- If only Doc is present -->
<tr>
<td width="13%" align="center" uniqueID="ms__id32">""</td>
<td width="13%" align="center" uniqueID="ms__id33">""</td>
<td width="13%" align="center" uniqueID="ms__id34">D000003</td>
<td width="13%" align="center" uniqueID="ms__id35">Design Spec</td>
<td width="13%" align="center" uniqueID="ms__id36">A</td>
</tr>
<!-- If only AML is present -->
<tr>
<td width="13%" align="center" uniqueID="ms__id32">Nickel</td>
<td width="13%" align="center" uniqueID="ms__id33">000T</td>
<td width="13%" align="center" uniqueID="ms__id34">""</td>
<td width="13%" align="center" uniqueID="ms__id35">""</td>
<td width="13%" align="center" uniqueID="ms__id36">""</td>
</tr>
Desired Full HTML Output
<html xmlns:aras="http://www.aras-corp.com">
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-16">
</head>
<style type="text/css" userData="Global">
table {empty-cells:show; border-collapse:collapse;}
th {font-family:helvetica; font-size:8pt; padding:2px; border:1px #000000 solid; background-color:#CCCCCC; text-transform:capitalize;}
td {font-family:helvetica; font-size:8pt; padding:2px; border:1px #000000 solid;}
td.noBorder {font-family:helvetica; font-size:8pt; padding:2px; border-width:0;}
</style>
<body topmargin="50" leftmargin="50">
<table border="0" cellspacing="0" cellpadding="0" width="1850">
<tr valign="top">
</tr>
<tr valign="bottom">
<td class="noBorder" colspan="13" style="font-family:helvetica;font-size:15pt;color:#DA1943;padding:2px;" align="left" uniqueID="ms__id22">Bill of Materials Report - 9.6 Hz Parts Rev 1</td>
<td class="noBorder" colspan="7" style="font-family:helvetica;font-size:10pt;padding:2px;" align="right" uniqueID="ms__id23">Generated on: <script>function m00(r, n){r += ""; if (!n) n = 2; while(r.length < n){r = "0" + r;} return r;} var dt = new Date(); var a = top.opener.top.aras; if (a){var s = m00(dt.getUTCFullYear(),4)+"-"+m00((dt.getUTCMonth()+1))+"-"+m00(dt.getUTCDate())+"T"+m00(dt.getUTCHours())+":"+m00(dt.getUTCMinutes())+":"+m00(dt.getUTCSeconds())+"+0000"; s = a.convertToNeutral(s, "date", "yyyy-MM-ddTHH:mm:sszzz"); s = a.convertFromNeutral(s, "date", "short_date"); document.write(s);}</script></td>
</tr>
<tr>
<th colspan="6">Indenture Level</th>
<th>Part Number</th>
<th>Legacy Part Number</th>
<th>Revision</th>
<th>Name</th>
<th>Description</th>
<th>Parameters</th>
<th>RoHS/Pb-Free</th>
<th>Quantity</th>
<th>Reference Designator</th>
<th>Manufacturer</th>
<th>Manufacturer Part</th>
<th>Document Number</th>
<th>Document Name</th>
<th>Document Rev</th>
<th>Pos AML</th>
<th>Pos Doc</th>
<th>Mod</th>
</tr>
<tr>
<td rowspan="3" width="2%" align="center" uniqueID="ms__id10">0</td>
<td rowspan="3" width="2%" align="center" uniqueID="ms__id11"></td>
<td rowspan="3" width="2%" align="center" uniqueID="ms__id12"></td>
<td rowspan="3" width="2%" align="center" uniqueID="ms__id13"></td>
<td rowspan="3" width="2%" align="center" uniqueID="ms__id14"></td>
<td rowspan="3" width="2%" align="center" uniqueID="ms__id15"></td>
<td rowspan="3" width="5%" align="center" uniqueID="ms__id16">E008643</td>
<td rowspan="3" width="5%" align="center" uniqueID="ms__id17"></td>
<td rowspan="3" width="2%" align="center" uniqueID="ms__id18">1</td>
<td rowspan="3" width="13%" align="center" uniqueID="ms__id19">9.6 Hz Parts</td>
<td rowspan="3" width="13%" align="center" uniqueID="ms__id20">Test</td>
<td rowspan="3" width="13%" align="center" uniqueID="ms__id21">Assembly</td>
<td rowspan="3" width="5%" align="center" uniqueID="ms__id22"></td>
<td rowspan="3" width="5%" align="center" uniqueID="ms__id23">1</td>
<td rowspan="3" width="5%" align="center" uniqueID="ms__id24"></td>
<td width="13%" align="center" uniqueID="ms__id26">Fasteners Co.</td>
<td width="13%" align="center" uniqueID="ms__id27">009</td>
<td width="5%" align="center" uniqueID="ms__id28">D000006</td>
<td width="13%px" align="center" uniqueID="ms__id29">Hardware Doc</td>
<td width="8%" align="center" uniqueID="ms__id30">B</td>
<td rowspan="3" width="8%" align="center" uniqueID="ms__id37">2</td>
<td rowspan="3" width="8%" align="center" uniqueID="ms__id38">3</td>
<td rowspan="3" width="8%" align="center" uniqueID="ms__id40">true</td>
</tr>
<tr>
<td width="13%" align="center" uniqueID="ms__id32">Vishay/Dale</td>
<td width="13%" align="center" uniqueID="ms__id33">1234</td>
<td width="13%" align="center" uniqueID="ms__id34">D000005</td>
<td width="13%" align="center" uniqueID="ms__id35">Firmware</td>
<td width="13%" align="center" uniqueID="ms__id36">B</td>
</tr>
<tr>
<td width="13%" align="center" uniqueID="ms__id32"></td>
<td width="13%" align="center" uniqueID="ms__id33"></td>
<td width="13%" align="center" uniqueID="ms__id34">D000003</td>
<td width="13%" align="center" uniqueID="ms__id35">Design Spec</td>
<td width="13%" align="center" uniqueID="ms__id36">A</td>
</tr>
<tr>
<td rowspan="5" width="2%" align="center" uniqueID="ms__id10"></td>
<td rowspan="5" width="2%" align="center" uniqueID="ms__id11">1</td>
<td rowspan="5" width="2%" align="center" uniqueID="ms__id12"></td>
<td rowspan="5" width="2%" align="center" uniqueID="ms__id13"></td>
<td rowspan="5" width="2%" align="center" uniqueID="ms__id14"></td>
<td rowspan="5" width="2%" align="center" uniqueID="ms__id15"></td>
<td rowspan="5" width="5%" align="center" uniqueID="ms__id16">E000371</td>
<td rowspan="5" width="5%" align="center" uniqueID="ms__id17">0061</td>
<td rowspan="5" width="2%" align="center" uniqueID="ms__id18">A</td>
<td rowspan="5" width="13%" align="center" uniqueID="ms__id19">0?</td>
<td rowspan="5" width="13%" align="center" uniqueID="ms__id20">Thick Film ''</td>
<td rowspan="5" width="13%" align="center" uniqueID="ms__id21">0, 100, 0.05</td>
<td rowspan="5" width="5%" align="center" uniqueID="ms__id22">Yes</td>
<td rowspan="5" width="5%" align="center" uniqueID="ms__id23">1</td>
<td rowspan="5" width="5%" align="center" uniqueID="ms__id24">R34</td>
<td width="13%" align="center" uniqueID="ms__id26">Speer</td>
<td width="13%" align="center" uniqueID="ms__id27">RK73Z1JTTD</td>
<td width="5%" align="center" uniqueID="ms__id28">D000010</td>
<td width="13%px" align="center" uniqueID="ms__id29">BOX</td>
<td width="8%" align="center" uniqueID="ms__id30">B</td>
<td rowspan="5" width="8%" align="center" uniqueID="ms__id37">5</td>
<td rowspan="5" width="8%" align="center" uniqueID="ms__id38">3</td>
<td rowspan="5" width="8%" align="center" uniqueID="ms__id40">false</td>
</tr>
<tr>
<td width="13%" align="center" uniqueID="ms__id32">Nickel</td>
<td width="13%" align="center" uniqueID="ms__id33">000T</td>
<td width="13%" align="center" uniqueID="ms__id34">D000011</td>
<td width="13%" align="center" uniqueID="ms__id35">SOCKET</td>
<td width="13%" align="center" uniqueID="ms__id36">A</td>
</tr>
<tr>
<td width="13%" align="center" uniqueID="ms__id32">Sonic</td>
<td width="13%" align="center" uniqueID="ms__id33">R00V</td>
<td width="13%" align="center" uniqueID="ms__id34">D000007</td>
<td width="13%" align="center" uniqueID="ms__id35">MOUNT</td>
<td width="13%" align="center" uniqueID="ms__id36">A</td>
</tr>
<tr>
<td width="13%" align="center" uniqueID="ms__id32">NIC</td>
<td width="13%" align="center" uniqueID="ms__id33">OTRF</td>
<td width="13%" align="center" uniqueID="ms__id34"></td>
<td width="13%" align="center" uniqueID="ms__id35"></td>
<td width="13%" align="center" uniqueID="ms__id36"></td>
</tr>
<tr>
<td width="13%" align="center" uniqueID="ms__id32">Test</td>
<td width="13%" align="center" uniqueID="ms__id33">9874</td>
<td width="13%" align="center" uniqueID="ms__id34"></td>
<td width="13%" align="center" uniqueID="ms__id35"></td>
<td width="13%" align="center" uniqueID="ms__id36"></td>
</tr>
<tr>
<td rowspan="2" width="2%" align="center" uniqueID="ms__id10"></td>
<td rowspan="2" width="2%" align="center" uniqueID="ms__id11">1</td>
<td rowspan="2" width="2%" align="center" uniqueID="ms__id12"></td>
<td rowspan="2" width="2%" align="center" uniqueID="ms__id13"></td>
<td rowspan="2" width="2%" align="center" uniqueID="ms__id14"></td>
<td rowspan="2" width="2%" align="center" uniqueID="ms__id15"></td>
<td rowspan="2" width="5%" align="center" uniqueID="ms__id16">E001163</td>
<td rowspan="2" width="5%" align="center" uniqueID="ms__id17">0145</td>
<td rowspan="2" width="2%" align="center" uniqueID="ms__id18">A</td>
<td rowspan="2" width="13%" align="center" uniqueID="ms__id19">8200</td>
<td rowspan="2" width="13%" align="center" uniqueID="ms__id20">PPS Film ''</td>
<td rowspan="2" width="13%" align="center" uniqueID="ms__id21">
</td>
<td rowspan="2" width="5%" align="center" uniqueID="ms__id22">Yes</td>
<td rowspan="2" width="5%" align="center" uniqueID="ms__id23">30</td>
<td rowspan="2" width="5%" align="center" uniqueID="ms__id24">C1-C5,C12,C17,C22,C25,C27-C29,C31</td>
<td width="13%" align="center" uniqueID="ms__id26">Sonic</td>
<td width="13%" align="center" uniqueID="ms__id27">822GX5</td>
<td width="5%" align="center" uniqueID="ms__id28">D000012</td>
<td width="13%px" align="center" uniqueID="ms__id29">Doc Test</td>
<td width="8%" align="center" uniqueID="ms__id30">A</td>
<td rowspan="2" width="8%" align="center" uniqueID="ms__id37">2</td>
<td rowspan="2" width="8%" align="center" uniqueID="ms__id38">2</td>
<td rowspan="2" width="8%" align="center" uniqueID="ms__id40">true</td>
</tr>
<tr>
<td width="13%" align="center" uniqueID="ms__id32"></td>
<td width="13%" align="center" uniqueID="ms__id33"></td>
<td width="13%" align="center" uniqueID="ms__id34">D000008</td>
<td width="13%" align="center" uniqueID="ms__id35">ADAPTER</td>
<td width="13%" align="center" uniqueID="ms__id36">A</td>
</tr>
</table>
</body><script src="../../javascript/PopupMenu.js"></script><script src="../../javascript/PopupMenu.js"></script><script src="../../javascript/PopupMenu.js"></script><script src="../../javascript/PopupMenu.js"></script></html>
What XSLT processor are you using?
I believe this should do what you want:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:aras="http://www.aras-corp.com" exclude-result-prefixes="msxsl">
<xsl:output method="html" omit-xml-declaration="yes" standalone="yes" indent="yes"></xsl:output>
<xsl:template match="/">
<html>
<head></head>
<style type="text/css" userData="Global">
table {empty-cells:show; border-collapse:collapse;}
th {font-family:helvetica; font-size:8pt; padding:2px; border:1px #000000 solid; background-color:#CCCCCC; text-transform:capitalize;}
td {font-family:helvetica; font-size:8pt; padding:2px; border:1px #000000 solid;}
td.noBorder {font-family:helvetica; font-size:8pt; padding:2px; border-width:0;}
</style>
<body topmargin="50" leftmargin="50">
<table border="0" cellspacing="0" cellpadding="0" width="1850">
<tr valign="top">
<td class="noBorder" align="left" colspan="9" uniqueID="ms__id39">
</td>
</tr>
<tr valign="bottom">
<td class="noBorder" colspan="13" style="font-family:helvetica;font-size:15pt;color:#DA1943;padding:2px;" align="left" uniqueID="ms__id22">
Bill of Materials Report - <xsl:value-of select="//Item/name"></xsl:value-of> Rev <xsl:value-of select="//Item/major_rev"></xsl:value-of>
</td>
<td class="noBorder" colspan="7" style="font-family:helvetica;font-size:10pt;padding:2px;" align="right" uniqueID="ms__id23">
Generated on: <script>function m00(r, n){r += ""; if (!n) n = 2; while(r.length < n){r = "0" + r;} return r;} var dt = new Date(); var a = top.opener.top.aras; if (a){var s = m00(dt.getUTCFullYear(),4)+"-"+m00((dt.getUTCMonth()+1))+"-"+m00(dt.getUTCDate())+"T"+m00(dt.getUTCHours())+":"+m00(dt.getUTCMinutes())+":"+m00(dt.getUTCSeconds())+"+0000"; s = a.convertToNeutral(s, "date", "yyyy-MM-ddTHH:mm:sszzz"); s = a.convertFromNeutral(s, "date", "short_date"); document.write(s);}</script>
</td>
</tr>
<tr>
<th width="12%" colspan="6">Indent Level</th>
<th width="5%">Part Number</th>
<th width="13%">Manufacturer</th>
<th width="13%">Manufacturer Part</th>
<th width="13%">Document Number</th>
<th width="13%">Document Name</th>
<th width="13%">Document Rev</th>
<th width="8%">Pos AML</th>
<th width="8%">Pos Doc</th>
<th width="8%">Mod</th>
</tr>
<xsl:apply-templates select="//Item[#type='Part']"></xsl:apply-templates>
</table>
</body>
<script src="../../javascript/PopupMenu.js"></script>
<script src="../../javascript/PopupMenu.js"></script>
<script src="../../javascript/PopupMenu.js"></script>
<script src="../../javascript/PopupMenu.js"></script>
</html>
</xsl:template>
<xsl:template match="Item[#type='Part']">
<xsl:variable name="AmlItems" select="Relationships/Item[#type='Part AML']"/>
<xsl:variable name="DocItems" select="Relationships/Item[#type='Part Document']"/>
<xsl:variable name="MoreAmlItems" select="count($AmlItems) > count($DocItems)" />
<xsl:variable name="largerGroup" select="$AmlItems[$MoreAmlItems] | $DocItems[not($MoreAmlItems)]" />
<!-- Ensure rowCount is at least 1 -->
<xsl:variable name="rowCount" select="count($largerGroup) + (count($largerGroup) = 0)"/>
<!-- Grab values -->
<tr>
<xsl:call-template name="IndentLevel">
<xsl:with-param name="rowSpan" select="$rowCount" />
</xsl:call-template>
<td rowspan="{$rowCount}" align="center" uniqueID="ms__id16">
<xsl:value-of select="item_number"></xsl:value-of>
</td>
<xsl:apply-templates select="$largerGroup[1]" />
<td rowspan="{$rowCount}" align="center" uniqueID="ms__id37">
<xsl:value-of select="count($AmlItems)"></xsl:value-of>
</td>
<td rowspan="{$rowCount}" align="center" uniqueID="ms__id38">
<xsl:value-of select="count($DocItems)"></xsl:value-of>
</td>
<td rowspan="{$rowCount}" align="center" uniqueID="ms__id40">
<xsl:value-of select="position() mod 2 = 1"></xsl:value-of>
</td>
</tr>
<!-- Assing first row for AML and Doc -->
<xsl:apply-templates select="$largerGroup[position() > 1]"></xsl:apply-templates>
</xsl:template>
<xsl:template name="IndentLevel">
<xsl:param name="level" select="0" />
<xsl:param name="rowSpan" />
<td rowspan="{$rowSpan}" width="2%" align="center" uniqueID="ms__id{10+$level}">
<xsl:if test="count(ancestor::Item[#type = 'Part']) = $level">
<xsl:value-of select="$level"/>
</xsl:if>
</td>
<!-- Stop when we reach 5 -->
<xsl:if test="$level < 5">
<xsl:call-template name="IndentLevel">
<xsl:with-param name="level" select="$level + 1" />
<xsl:with-param name="rowSpan" select="$rowSpan" />
</xsl:call-template>
</xsl:if>
</xsl:template>
<!-- AML and Doc Rows 2+ -->
<xsl:template match="text()" />
<xsl:template match="Item[#type = 'Part AML']">
<xsl:variable name="pos" select="position()" />
<xsl:variable name="isTop" select="not(preceding-sibling::Item[#type = 'Part AML'])"/>
<xsl:call-template name="ItemRow">
<xsl:with-param name="AmlItem" select="." />
<xsl:with-param name="PartDocument" select="../Item[#type = 'Part Document'][position() = $pos + not($isTop)]" />
<xsl:with-param name="IsTop" select="$isTop" />
</xsl:call-template>
</xsl:template>
<xsl:template match="Item[#type='Part Document']">
<xsl:variable name="pos" select="position()" />
<xsl:variable name="isTop" select="not(preceding-sibling::Item[#type = 'Part Document'])"/>
<xsl:call-template name="ItemRow">
<xsl:with-param name="AmlItem" select="../Item[#type = 'Part AML'][position() = $pos + not($isTop)]" />
<xsl:with-param name="PartDocument" select="." />
<xsl:with-param name="IsTop" select="$isTop" />
</xsl:call-template>
</xsl:template>
<xsl:template name="ItemRow">
<xsl:param name="AmlItem" />
<xsl:param name="PartDocument" select="_" />
<xsl:param name="IsTop" />
<xsl:variable name="startingId" select="26 * $IsTop + 32 * not($IsTop)" />
<xsl:variable name="rowData">
<cell value="{$AmlItem/related_id/Item/manufacturer/#keyed_name}" />
<cell value="{$AmlItem/related_id/Item[#type='Manufacturer Part']/item_number}" />
<cell value="{$PartDocument/related_id[#type='Document']/Item/item_number}" />
<cell value="{$PartDocument/related_id[#type='Document']/Item/name}" />
<cell value="{$PartDocument/related_id[#type='Document']/Item/major_rev}" />
</xsl:variable>
<xsl:variable name="rowCells">
<xsl:call-template name="RowCells">
<xsl:with-param name="rowData" select="$rowData" />
<xsl:with-param name="startingId" select="$startingId" />
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="$IsTop">
<xsl:copy-of select="$rowCells"/>
</xsl:when>
<xsl:otherwise>
<tr>
<xsl:copy-of select="$rowCells"/>
</tr>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="RowCells">
<xsl:param name="rowData" />
<xsl:param name="startingId" />
<xsl:for-each select="msxsl:node-set($rowData)/cell">
<td align="center" uniqueID="ms__id{$startingId + position() - 1}">
<xsl:value-of select="#value"/>
</td>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
If you're using a non-Microsoft XSLT processor, you would need to change the msxsl namespace to something else according to the table on this page:
http://www.xml.com/pub/a/2003/07/16/nodeset.html
There seems to be an inconsistency between your source XML and your output. The <related_id> in the first Item has no type attribute, so your [#type='Manufacturer Part'] filter would fail to locate anything. Is there supposed to be a type attribute there?
In your first template I would change it like this.
<xsl:template match="Item[#type='Part AML']|Item[#type='Part Document']">
<tr>
<xsl:apply-templates select="related_id/Item/manufacturer/#keyed_name"/>
...
</tr>
</xsl:template>
That should build out your rows like you want.

selecting drop-down value in xsl

How to select the drop down value ? Am trying to display some data whenever I select some value in a drop-down in xsl. For example, If A is selected in the drop-down, details pertaining to A will be displayed in a table. Similarly, if B is selcted, only details relevant to B will be displayed. I need to write a line of code in xslt to select the drop down value in an if statement.
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title>VPGate Media Mixer</title>
<meta http-equiv="expires" content="0"/>
<meta http-equiv="pragma" content="no-cache"/>
<meta http-equiv="cache-control" content="no-cache, must-revalidate"/>
<meta http-equiv="refresh" content="15"></meta>
<script src="/Common/common.js\" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="style001.css" />
<link rel="stylesheet" type="text/css" href="Grid.Default.css" />
</head>
<body class="WorkArea">
<div class="divSummaryHeader" id="SummaryHeader">
<h1>Media Mixer - VPGate</h1>
</div>
 
<div class="RadGrid RadGrid_Default" id="SummaryData" style="position:absolute;width:828px;height:510px;overflow:auto">
<table border="0" class="rgMasterTable rgClipCells" cellspacing="0" cellpadding="0" >
<tr>
<input type="button" class="formEditBtn" id="SubBtn" value="Refresh" onclick="window.location=window.location;"/>
</tr>
<tr>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;" colspan="2">Conference Summary</td>
</tr>
<tr>
<td>
<table border="0" class="rgMasterTable rgClipCells" cellspacing="0" cellpadding="0" >
<tr>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Conference Name</td>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Conference ID</td>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Composite Address</td>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Composite Port</td>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Composite Ssrc</td>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">No Of Participants</td>
</tr>
<xsl:if test="MediaMixer!= ''">
<xsl:for-each select="MediaMixer/Conference">
<!--<xsl:sort select="Name"/>-->
<xsl:if test="Name !=''">
<xsl:if test="(position() mod 2 = 0)">
<tr class="rgAltRow SummaryTableDataRow">
<td valign = "top">
<xsl:value-of select="Name"/>
</td>
<td valign = "top">
<xsl:value-of select="ConfId"/>
</td>
<td valign = "top">
<xsl:value-of select="CompositeAddress"/>
</td>
<td valign = "top">
<xsl:value-of select="CompositePort"/>
</td>
<td valign = "top">
<xsl:value-of select="CompositeSsrc"/>
</td>
<td valign = "top">
<xsl:value-of select="NoOfParticipants"/>
</td>
</tr>
</xsl:if>
<xsl:if test="(position() mod 2 = 1)">
<td>
<tr class="rgRow SummaryTableDataRow">
<td valign = "top">
<xsl:value-of select="Name"/>
</td>
<td valign = "top">
<xsl:value-of select="ConfId"/>
</td>
<td valign = "top">
<xsl:value-of select="CompositeAddress"/>
</td>
<td valign = "top">
<xsl:value-of select="CompositePort"/>
</td>
<td valign = "top">
<xsl:value-of select="CompositeSsrc"/>
</td>
<td valign = "top">
<xsl:value-of select="NoOfParticipants"/>
</td>
</tr>
</td>
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:if>
<xsl:if test="MediaMixer = ''">
<td valign = "top">
<xsl:text>No Data </xsl:text>
</td>
</xsl:if>
</table>
</td>
</tr>
</table>
 
<div align="center">
<b> Please select a Conference Name :</b>
 
<select name="combo" id="combo">
<xsl:for-each select="MediaMixer/Conference">
<option>
<xsl:value-of select="Name"/>
</option>
</xsl:for-each>
</select>
</div>
<script type="text/C#" runat="server">
</script>
<table border="0" class="rgMasterTable rgClipCells" cellspacing="1" cellpadding="1">
<tr>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;" colspan="2">Conference Details</td>
</tr>
<tr>
<td>
<table border="0" class="rgMasterTable rgClipCells" cellspacing="0" cellpadding="0" >
<tr>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Conference Name</td>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Conference ID</td>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Participant ID 1</td>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Participant ID 2</td>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Participant Address</td>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Participant Listening Port</td>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">MM Listening Port</td>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">SSRC From Participant</td>
<td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">SSRC From MM</td>
</tr>
<xsl:if test="MediaMixer!= ''">
<xsl:for-each select="MediaMixer/Conference">
<xsl:if test="Name='combo.SelectedValue'">
<xsl:for-each select="Participant">
<xsl:if test="(position() mod 2 = 0)">
<tr class="rgAltRow SummaryTableDataRow">
<td valign = "top">
<xsl:value-of select="../Name"/>
</td>
<td valign = "top">
<xsl:value-of select="../ConfId"/>
</td>
<td valign = "top">
<xsl:value-of select="translate(ID1,
'abcdefghijklmnopqrstuvwxyz',
'ABCDEFGHIJKLMNOPQRSTUVWXYZ')" />
</td>
<td valign = "top">
<xsl:value-of select="ID2"/>
</td>
<td valign = "top">
<xsl:value-of select="ParticipantAddress"/>
</td>
<td valign = "top">
<xsl:value-of select="ParticipantListeningPort"/>
</td>
<td valign = "top">
<xsl:value-of select="MMListeningPort"/>
</td>
<td valign = "top">
<xsl:value-of select="SSRCFromParticipant"/>
</td>
<td valign = "top">
<xsl:value-of select="SSRCFromMM"/>
</td>
</tr>
</xsl:if>
<xsl:if test="(position() mod 2 = 1)">
<td>
<tr class="rgRow SummaryTableDataRow">
<td valign = "top">
<xsl:value-of select="../Name"/>
</td>
<td valign = "top">
<xsl:value-of select="../ConfId"/>
</td>
<td valign = "top">
<xsl:value-of select="translate(ID1,
'abcdefghijklmnopqrstuvwxyz',
'ABCDEFGHIJKLMNOPQRSTUVWXYZ')" />
</td>
<td valign = "top">
<xsl:value-of select="ID2"/>
</td>
<td valign = "top">
<xsl:value-of select="ParticipantAddress"/>
</td>
<td valign = "top">
<xsl:value-of select="ParticipantListeningPort"/>
</td>
<td valign = "top">
<xsl:value-of select="MMListeningPort"/>
</td>
<td valign = "top">
<xsl:value-of select="SSRCFromParticipant"/>
</td>
<td valign = "top">
<xsl:value-of select="SSRCFromMM"/>
</td>
</tr>
</td>
</xsl:if>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</xsl:if>
<xsl:if test="MediaMixer= ''">
<td valign = "top">
<xsl:text>No Data </xsl:text>
</td>
</xsl:if>
</table>
</td>
</tr>
</table>
 
<div style="display:none">
<iframe id="frameUpdate" name="frameUpdate" width="100%"></iframe>
</div>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
If you are building a HTML page out of XML data with client side XSLT in the Browser, be aware that XSLT can only define the transformation process. When the HTML is ready, XSLT has finished its job. What you can do is to insert javascript into the XSLT source, that reacts on drop-down changes and hides the inappropiate data. The XSLT can't communicate with the Javascript, because the Javascript will begin to work after the page is complete and XSLT is already finished. But it can fit the javascript into the HTML source. Just imagine how to work this out in plain HTML without XSLT and let XSLT build this HTML.

How xsl will work when "xmlns" attribute exist in a node of xml

My xsl is working fine when "xmlns" attribute doesn't exist in a node integration_test_results of xml. What i can do in xsl so it will work when "xmlns" attribute exist in integration_test_results node.
Please help me ASAP.
Here i am attaching my xml and xsl file:
Attach xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?xml-stylesheet href="framework_results.xsl" type="text/xsl" ?>
<integration_test_results xmlns="http://schemas.oracle.com/dm/v2009">
<test>
<name>Reg_Table_test_1</name>
<status>PASSED</status>
<start_time>2010-10-19 05:04:58.011</start_time>
<finish_time>2010-10-19 05:07:29.779</finish_time>
<test_duration>0</test_duration>
<datamover_job>
<status>COMPLETED_SUCCESSFUL</status>
<start_time>2010-10-19 05:04:58.011</start_time>
<finish_time>2010-10-19 05:07:29.779</finish_time>
<job_duration>0</job_duration>
</datamover_job>
</test>
</integration_test_results>
Attach xsl:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns="http://schemas.oracle.com/dm/v2009">
<xsl:template match="ns:integration_test_results">
<html>
<body>
<h2 align="center">Test Report</h2>
<table border="1" align="center">
<tr bgcolor="orange">
<Th colspan="2">Results </Th>
</tr>
<tr>
<th align="Left" bgcolor="orange">Tests passed/Failed/Skipped:</th>
<td>
<xsl:value-of select="count(test[status='PASSED'])" /> /
<xsl:value-of select="count(test[status='FAILED'])" /> /
<xsl:value-of select="count(test[status='RUNNING'])" />
</td>
</tr>
<tr>
<th align="Left" bgcolor="orange">Started on:</th>
<xsl:for-each select="test">
<xsl:sort select="start_time" order="ascending" data-type="text" />
<xsl:if test="position()=1">
<TD>
<xsl:value-of select="start_time" />
</TD>
</xsl:if>
</xsl:for-each>
</tr>
<tr>
<th align="Left" bgcolor="orange">Total time:</th>
<td>
<xsl:value-of select="sum(test/test_duration[number(.)=number(.)])" />
</td>
</tr>
<tr>
<th align="Left" bgcolor="orange">Included groups:</th>
<td>
<!-- <xsl:value-of select="" /> -->
</td>
</tr>
<tr>
<th align="Left" bgcolor="orange">Excluded groups:</th>
<td>
<!-- <xsl:value-of select="" /> -->
</td>
</tr>
</table>
<br></br>
<table border="1">
<tr bgcolor="orange">
<th rowspan="2">Test Name</th>
<th rowspan="2">Test Results</th>
<th rowspan="2">Start Time(sec)</th>
<th rowspan="2">End Time(sec)</th>
<th rowspan="2">Test Duration(sec)</th>
<th rowspan="2">Message</th>
<th colspan="5">DM JOB</th>
</tr>
<tr bgcolor="orange">
<th>Job Name</th>
<th>Job Results</th>
<th>Start Time(sec)</th>
<th>End Time(sec)</th>
<th>Job Duration(sec)</th>
</tr>
<xsl:for-each select="test">
<xsl:sort select="start_time" order="ascending" data-type="text" />
<tr>
<td>
<xsl:value-of select="name" />
</td>
<td>
<xsl:value-of select="status"/>
</td>
<td>
<xsl:value-of select="start_time" />
</td>
<td>
<xsl:value-of select="finish_time" />
</td>
<td>
<xsl:value-of select="test_duration"/>
</td>
<td>
<xsl:value-of select="message" />
</td>
<xsl:for-each select="datamover_job">
<td>
<xsl:value-of select="name" />
</td>
<td>
<xsl:value-of select="status"/>
</td>
<td>
<xsl:value-of select="start_time" />
</td>
<td>
<xsl:value-of select="finish_time" />
</td>
<td>
<xsl:value-of select="job_duration"/>
</td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
--Thanks
First, properly speaking, there is no xmlns attribute: this is a namespace declaration.
Second, you have an inconsistent way to deal with namespaces in your stylesheet's XPath expression: you have matched the root element with the proper namespace ns:integration_test_results but after that you no longer select it descendants with that namespace.
This is FAQ: Namespace declarations get propagate to descendants.
Try prefixing the rest of the elements just you prefixed
match="ns:integration_test_results"
In the xml you have the default namespace. In the xsl you bind a prefix ns to the same namespace. Therefore, you need to prefix the rest of the elements.
Here is a partial change. Sorry I don't have time to do the rest, but you can figure it out yourself..
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns="http://schemas.oracle.com/dm/v2009">
<xsl:template match="ns:integration_test_results">
<html>
<body>
<h2 align="center">Test Report</h2>
<table border="1" align="center">
<tr bgcolor="orange">
<Th colspan="2">Results </Th>
</tr>
<tr>
<th align="Left" bgcolor="orange">Tests passed/Failed/Skipped:</th>
<td>
<xsl:value-of select="count(ns:test[ns:status='PASSED'])"/> /
<xsl:value-of select="count(ns:test[ns:status='FAILED'])"/> /
<xsl:value-of select="count(ns:test[ns:status='RUNNING'])"/>
</td>
</tr>
<tr>
<th align="Left" bgcolor="orange">Started on:</th>
<xsl:for-each select="ns:test">
<xsl:sort select="ns:start_time" order="ascending" data-type="text"/>
<xsl:if test="position()=1">
<TD>
<xsl:value-of select="ns:start_time"/>
</TD>
</xsl:if>
</xsl:for-each>
</tr>
<tr>
<th align="Left" bgcolor="orange">Total time:</th>
<td>
<xsl:value-of select="sum(/ns:test/ns:test_duration[number(.)=number(.)])"/>
</td>
</tr>
<tr>
<th align="Left" bgcolor="orange">Included groups:</th>
<td>
<!-- <xsl:value-of select="" /> -->
</td>
</tr>
<tr>
<th align="Left" bgcolor="orange">Excluded groups:</th>
<td>
<!-- <xsl:value-of select="" /> -->
</td>
</tr>
</table>
<br/>
<table border="1">
<tr bgcolor="orange">
<th rowspan="2">Test Name</th>
<th rowspan="2">Test Results</th>
<th rowspan="2">Start Time(sec)</th>
<th rowspan="2">End Time(sec)</th>
<th rowspan="2">Test Duration(sec)</th>
<th rowspan="2">Message</th>
<th colspan="5">DM JOB</th>
</tr>
<tr bgcolor="orange">
<th>Job Name</th>
<th>Job Results</th>
<th>Start Time(sec)</th>
<th>End Time(sec)</th>
<th>Job Duration(sec)</th>
</tr>
<xsl:for-each select="ns:test">
<xsl:sort select="ns:start_time" order="ascending" data-type="text"/>
<tr>
<td>
<xsl:value-of select="ns:name"/>
</td>
<td>
<xsl:value-of select="ns:status"/>
</td>
<td>
<xsl:value-of select="ns:start_time"/>
</td>
<td>
<xsl:value-of select="ns:finish_time"/>
</td>
<td>
<xsl:value-of select="ns:test_duration"/>
</td>
<td>
<xsl:value-of select="ns:message"/>
</td>
<xsl:for-each select="ns:datamover_job">
<td>
<xsl:value-of select="ns:name"/>
</td>
<td>
<xsl:value-of select="ns:status"/>
</td>
<td>
<xsl:value-of select="ns:start_time"/>
</td>
<td>
<xsl:value-of select="ns:finish_time"/>
</td>
<td>
<xsl:value-of select="ns:job_duration"/>
</td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>