Hi I have the following XML
<?xml version="1.0" encoding="UTF-8"?>
<catalog catalog-id="Primary">
<product product-id="clothes">
<items>
<item item-name="TShirt">Brown</item>
<item item-name="Pants">Green</item>
<item item-name="Shirt">White</item>
</items>
</product>
<product product-id="toys">
<items>
<item item-name="Ball">Cyan</item>
<item item-name="Bat">Green</item>
<item item-name="Racket">Blue</item>
</items>
</product>
</catalog>
The criteria is to only copy where "item-name" attribute value is either TShirt, Ball or Bat. So the resulting XML should look like
<?xml version="1.0" encoding="UTF-8"?>
<catalog catalog-id="Primary">
<product product-id="clothes">
<items>
<item item-name="TShirt">Brown</item>
</items>
</product>
<product product-id="toys">
<items>
<item item-name="Ball">Cyan</item>
<item item-name="Bat">Green</item>
</items>
</product>
</catalog>
I am using the following XSLT
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>
<xs:WhiteList>
<item-name>TShirt</item-name>
<item-name>Ball</item-name>
<item-name>Green</item-name>
</xs:WhiteList>
<xsl:variable name="whiteList" select="document('')/*/xs:WhiteList" />
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[(descendant-or-self::*[name()=$whiteList/item-name])"/>
</xsl:stylesheet>
But this does not work. Can you help please?
Thanks Nathan