Here is a sample stylesheet:
Code:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="root">
<xsl:copy>
<xsl:apply-templates select="@* | nodes"/>
</xsl:copy>
</xsl:template>
<xsl:template match="node[name = /root/items/item/name]"/>
</xsl:stylesheet>
When applied to this input XML
Code:
<root>
<nodes>
<node>
<name>
AAA
</name>
<value>
1
</value>
</node>
<node>
<name>
BBB
</name>
<value>
2
</value>
</node>
<node>
<name>
CCC
</name>
<value>
3
</value>
</node>
</nodes>
<items>
<item>
<name>
AAA
</name>
</item>
<item>
<name>
CCC
</name>
</item>
</items>
</root>
then the result with Saxon 6.5.5 is
Code:
<?xml version="1.0" encoding="utf-8"?><root><nodes>
<node>
<name>
BBB
</name>
<value>
2
</value>
</node>
</nodes></root>
The stylesheet uses the identity transformation template and then has two additional templates, one for the 'root' element to make sure that only the 'nodes' elements are processed but not the 'items' elements, and one empty template for 'node[name = /root/items/item/name]' elements to ensure that these are not copied. That should suffice, no need for any loops.
--
Martin Honnen
Microsoft MVP - XML