【发布时间】:2010-08-14 17:43:30
【问题描述】:
我正在进行 XSL 开发,我需要知道 XPATH 中的 NOT IN 等价物。 我以所有人都能理解的最简单的格式呈现 XML 和 XSL。
<?xml-stylesheet type="text/xsl" href="XSL.xsl"?>
<Message>
<Customers>
<Customer pin="06067">1</Customer>
<Customer pin="06068">2</Customer>
<Customer pin="06069">3</Customer>
<Customer pin="06070">4</Customer>
<Customer pin="06072">5</Customer>
</Customers>
<Addresses>
<Address pin1="06067">A</Address>
<Address pin1="06068">B</Address>
<Address pin1="06069">C</Address>
</Addresses>
</Message>
XSL
<xsl:template match="/Message">
<html>
<body>
<h4>Existing Customers</h4>
<table>
<xsl:apply-templates select="//Customers/Customer[@pin = //Addresses/Address/@pin1]"></xsl:apply-templates>
</table>
<h4>New Customers</h4>
<table>
<!--This place need to be filled with new customers-->
</table>
</body>
</html>
</xsl:template>
<xsl:template match="Customer" name="Customer">
<xsl:variable name="pin" select="./@pin"></xsl:variable>
<tr>
<td>
<xsl:value-of select="."/>
<xsl:text> is in </xsl:text>
<xsl:value-of select="//Addresses/Address[@pin1=$pin]"/>
</td>
</tr>
</xsl:template>
在上述 XSLT 中,在注释区域下,我需要匹配并显示 Addresses/Address 节点中不存在地址的客户。
请帮助找到与不在地址节点集中的客户匹配的 XPath 表达式。 (任何替代品也可以提供帮助)
【问题讨论】:
-
好问题 (+1)。请参阅我的答案以获取高效、简短且简单的 XSLT 解决方案。 :)