XML が次のようになっているとします。
<record>
<stuff>
<stuff term="foo"/>
<stuff term="bar"/>
<stuff term="test"/>
</stuff>
<other>
<other key="time"/>
<other key="rack"/>
<other key="foo"/>
<other key="fast"/>
</other>
</record>
キー属性に基づいて他の要素を検索するキーを設定できます
<xsl:key name="other" match="other/*" use="@key"/>
次に、一致する他の要素がないもの要素を選択するには、次のようにキーを使用します
<xsl:apply-templates select="stuff/*[not(key('other', @term))]"/>
次の XSLT を試してください
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:key name="other" match="other/*" use="@key"/>
<xsl:template match="/*">
<xsl:apply-templates select="stuff/*[not(key('other', @term))]"/>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
上記の XML に適用すると、次のように出力されます。
<stuff term="bar"></stuff>
<stuff term="test"></stuff>