我正在进行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>
Run Code Online (Sandbox Code Playgroud)
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>
Run Code Online (Sandbox Code Playgroud)
在上面的XSLT中,在注释区域下,我需要匹配并显示地址不存在于地址/地址节点中的客户.
请帮助查找与不在地址节点集中的客户匹配的XPath表达式.(任何替代方案也可以帮助)
小智 7
在XPath 1.0中:
/Message/Customers/Customer[not(@pin=/Message/Addresses/Address/@pin1)]
Run Code Online (Sandbox Code Playgroud)