我有一个大的XML文件和另一个小的XML文件,其名称与某些大型XML文件的属性值之一匹配。我想使用小的 XML 文件创建大型 XML 文件的记录子集。我的 XSL 尝试是这样的
<xsl:stylesheet xmlns:t="http://www.xyz.com/xml/Fixit" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="t:Fixit[.//t:Name[(@OrganisationName!=document('single_include.xml')//OrganisationName)]]"></xsl:template>
</xsl:stylesheet>
我的小XML文件"single_include.xml"是这样的
<ListOfOrganisationName>
<OrganisationName>
The first organisation
</OrganisationName>
<OrganisationName>
The second organisation
</OrganisationName>
</ListOfOrganisationName>
它似乎仅适用于第一张唱片。有什么想法吗?
希望这是有道理的。
排除"模板中的内部谓词
(@OrganisationName!=document('single_include.xml')//OrganisationName)
如果single_include.xml
中有任何OrganisationName
不等于当前元素的 OrganisationName
属性,则为 true。 这将排除"第二个组织",因为过滤文件中有一个不等于OrganisationName
("第一个组织"(。 相反,您可能想要
not(@OrganisationName=document('single_include.xml')//OrganisationName)
仅当single_include.xml
中没有等于当前元素的 OrganisationName
属性的OrganisationName
时,才为真。 XPath 规范在第 3.4 节中指出了这一点,其中说
注意:如果
$x
绑定到节点集,则$x="foo"
并不意味着与not($x!="foo")