if any placeholder element with attribute x=”test” + text element immediately follow an hg* record that is a duplicate needs to be removed below is the sample xml:
<block ID="IF5">
<codes ID="IF5" x="hg5">
<info>
<name>ARTICLE</name>
<designator>1</designator>
<info>
</codes>
<codes ID="IF5" x="hg5c">
<info>
<headtext>PUBLIC</headtext>
</info>
</codes>
<placeholder ID="IF526" x="test">
<text>SANA</text>
</placeholder>
<grade>
<text>SANA</text>
</grade>
<placeholder ID="IF526" x="test">
<text>SANA</text>
</placeholder>
</block>
expected output:
<block ID="IF5">
<codes ID="IF5" x="hg5">
<info>
<name>ARTICLE</name>
<designator>1</designator>
<info>
</codes>
<codes ID="IF5" x="hg5c">
<info>
<headtext>PUBLIC</headtext>
</info>
</codes>
<grade>
<text>SANA</text>
</grade>
<placeholder ID="IF526" x="test">
<text>SANA</text>
</placeholder>
</block>
my xslt code look like below:
<xsl:template match="placeholder[@x='test']" >
<xsl:choose>
<xsl:when test="preceding-sibling::*[1][codes[@x='hg*']]">
<!-- do nothing-->
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="@*|node()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>