I have xml as below:
<panel id="MainPanel" x="0" y="0" w="100%" h="100%" backgroundcolor="green" >
<panel id="somepanel" x="0" y="130" w="100%" h="PANEL_ALIGN" backgroundcolor="red" >
<panel id="nextpanel" x="0" y="130" w="100%" h="PANEL_ALIGN" backgroundcolor="red" >
<table id="TestPanel" x="1%" y="20" w="98%" h="PANEL_ALIGN""></table>
<table id="TestPanel" x="1%" y="20" w="98%" h="PANEL_ALIGN""></table>
<table id="TestPanel2" x="1%" y="20" w="98%" h="PANEL_ALIGN""></table>
</panel>
</panel>
Expected is:
<panel id="MainPanel" x="0" y="0" w="100%" h="100%" backgroundcolor="green" >
<panel id="somepanel" x="0" y="130" w="100%" h="PANEL_ALIGN" backgroundcolor="red" >
<panel id="nextpanel" x="0" y="130" w="100%" h="PANEL_ALIGN" backgroundcolor="red" >
<table id="TestPanel" x="1%" y="20" w="98%" h="PANEL_ALIGN""></table>
<table id="TestPanel2" x="1%" y="20" w="98%" h="PANEL_ALIGN""></table>
</panel>
</panel>
I use below xsl to remove table node but it removes all table node.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template
match="table"/>
</xsl:stylesheet>
Could anyone help , as i dont knwo much of xslt.
add this to your stylesheet as a top level:
<xsl:key name="kTable" match="table" use="@id"/>
and replace
<xsl:template match="table"/>
with
<xsl:template match="table[generate-id() != generate-id(key('kTable', @id)[1])]"/>