Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

How to remove a row from HTML table in XSLT template

$
0
0

I have a question regarding the XSLT template which transform my XML to HTML.

Here is the rough XML

<TopTerm ID="1" Entity="Term" Name="ENVIRONMENTAL MANAGEMENT"><ChildTerm ID="8" Entity="Term" Name="Auditing"><ChildTerm ID="36" Entity="Term" Name="Environmental audit" /><ChildTerm ID="46" Entity="Term" Name="Type of audit []" /></ChildTerm><ChildTerm ID="11" Entity="Term" Name="Incidents"><ChildTerm ID="71" Entity="Term" Name="Bruce Beresford" /><ChildTerm ID="35" Entity="Term" Name="Case name" /><ChildTerm ID="83" Entity="Term" Name="Jack Lemmon" /><ChildTerm ID="87" Entity="Term" Name="Mary  Pcikford" /></ChildTerm><ChildTerm ID="16" Entity="Term" Name="Monitoring" /><ChildTerm ID="18" Entity="Term" Name="Policies and procedures" /></TopTerm><TopTerm ID="4" Entity="Term" Name="HUMAN RESOURCE MANAGEMENT"><ChildTerm ID="7" Entity="Term" Name="Agreements" /><ChildTerm ID="14" Entity="Term" Name="Leave"><ChildTerm ID="32" Entity="Term" Name="Annual leave"><ChildTerm ID="42" Entity="Term" Name="Name of position" /><ChildTerm ID="46" Entity="Term" Name="Type of audit []" /><ChildTerm ID="48" Entity="Term" Name="Type of product" /></ChildTerm><ChildTerm ID="38" Entity="Term" Name="Maternity leave" /></ChildTerm><ChildTerm ID="17" Entity="Term" Name="Performance management" /><ChildTerm ID="20" Entity="Term" Name="Recruiting"><ChildTerm ID="42" Entity="Term" Name="Name of position" /></ChildTerm><ChildTerm ID="21" Entity="Term" Name="Remuneration" /><ChildTerm ID="12" Entity="Term" Name="Insurance" /></TopTerm>

Here is my XSLT

<?xml version='1.0'?><xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="html" encoding="utf-8"/><xsl:template match="/"><html><head>                  <title>Classification plan and Thesaurus</title></head><body><div id="wrapper"><table><tr><td>Process</td><td>Function</td><td>Activity</td></tr><xsl:apply-templates select="descendant-or-self::ChildTerm"/></table></div></body></html></xsl:template><xsl:template match="ChildTerm"><tr><xsl:for-each select="ancestor-or-self::*[@Entity='Term']"><td><xsl:value-of select="@Name"/></td>               </xsl:for-each></tr></xsl:template></xsl:stylesheet>

Applying the template will produce this HTML table

<table><tbody><tr><td>Process</td><td>Function</td><td>Activity</td></tr><tr><td>ENVIRONMENTAL MANAGEMENT</td><td>Auditing</td></tr><tr><td>ENVIRONMENTAL MANAGEMENT</td><td>Auditing</td><td>Environmental audit</td></tr><tr><td>ENVIRONMENTAL MANAGEMENT</td><td>Auditing</td><td>Type of audit []</td></tr><tr><td>ENVIRONMENTAL MANAGEMENT</td><td>Incidents</td></tr><tr><td>ENVIRONMENTAL MANAGEMENT</td><td>Incidents</td><td>Bruce Beresford</td></tr><tr><td>ENVIRONMENTAL MANAGEMENT</td><td>Incidents</td><td>Case name</td></tr><tr><td>ENVIRONMENTAL MANAGEMENT</td><td>Incidents</td><td>Jack Lemmon</td></tr><tr><td>ENVIRONMENTAL MANAGEMENT</td><td>Incidents</td><td>Mary  Pcikford</td></tr><tr><td>ENVIRONMENTAL MANAGEMENT</td><td>Monitoring</td></tr><tr><td>ENVIRONMENTAL MANAGEMENT</td><td>Policies and procedures</td></tr><tr><td>HUMAN RESOURCE MANAGEMENT</td><td>Agreements</td></tr><tr><td>HUMAN RESOURCE MANAGEMENT</td><td>Leave</td></tr><tr><td>HUMAN RESOURCE MANAGEMENT</td><td>Leave</td><td>Annual leave</td></tr><tr><td>HUMAN RESOURCE MANAGEMENT</td><td>Leave</td><td>Annual leave</td><td>Name of position</td></tr><tr><td>HUMAN RESOURCE MANAGEMENT</td><td>Leave</td><td>Annual leave</td><td>Type of audit []</td></tr><tr><td>HUMAN RESOURCE MANAGEMENT</td><td>Leave</td><td>Annual leave</td><td>Type of product</td></tr><tr><td>HUMAN RESOURCE MANAGEMENT</td><td>Leave</td><td>Maternity leave</td></tr><tr><td>HUMAN RESOURCE MANAGEMENT</td><td>Performance management</td></tr><tr><td>HUMAN RESOURCE MANAGEMENT</td><td>Recruiting</td></tr><tr><td>HUMAN RESOURCE MANAGEMENT</td><td>Recruiting</td><td>Name of position</td></tr><tr><td>HUMAN RESOURCE MANAGEMENT</td><td>Remuneration</td></tr><tr><td>HUMAN RESOURCE MANAGEMENT</td><td>Insurance</td></tr></tbody></table>

My question is: How do I remove the <tr> that only has 2 <td> IF and only IF the below <tr> has the same 2 <td> with an extra 3rd <td>

For example, this will be removed

<tr><td>ENVIRONMENTAL MANAGEMENT</td><td>Auditing</td></tr>

because the <tr> below has

<tr><td>ENVIRONMENTAL MANAGEMENT</td><td>Auditing</td><td>Type of audit []</td></tr>

Hope my question is clear, or else please tell me, I'll edit. Thanks guys


Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>