I have following xml file
<rules>
<rule>
<name>aa</name>
</rule>
<rule>
<name>cc</name>
</rule>
<rule>
<name>bb</name>
</rule>
</rules>
I would like to remove existing 3 rules and instead add new rule
<rule>
<name>zz</name>
</rule>
so the output should be
<rules>
<rule>
<name>zz</name>
</rule>
</rules>
I have tried this xslt ,
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="rule[name[text()='aa']]"/>
<xsl:template match="rule[name[text()='bb']]"/>
<xsl:template match="rule[name[text()='cc']]"/>
<xsl:template match="rule[position()=last()]">
<xsl:copy-of select="."/>
<rule>
<name>zz</name>
</rule>
</xsl:template>
</xsl:stylesheet>
but it produce this - (cc is not removed)
<rules>
<rule>
<name>cc</name>
</rule>
<rule>
<name>zz</name>
</rule>
</rules>
What is the problem with xslt ?
<xsl:copy-of select="."/>from your template - har07