vendredi 30 janvier 2015

Remove nodes from nodeset when nodeset length is more than 1

I have an xml like



<Books>
<Book Name="ABC">
<Line No="43"/>
</Book>
<Book Name="XYZ">
<Line No="44"/>
</Book>
</Books>


I have to remove where Name is "ABC" only when where Name is "XYZ" is also present (or where Name is "ABC" is not the only element in the nodeset)


The xslt i prepared is like :



<xsl:stylesheet xmlns:xsl="http://ift.tt/tCZ8VR" version="1.0">
<xsl:output method="xml" indent="yes" />
<xsl:if test="count(Books/Book) > '1'">
<xsl:strip-space elements="*" />
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="Book[@Name='ABC']" />
</xsl:if>
</xsl:stylesheet>


This does not seem to work. What is it that I am doing wrong here.


Aucun commentaire:

Enregistrer un commentaire