2012-07-25 44 views
0

我有一个大的XML文件和另一个小XML文件,名称与某些大型XML文件的某个属性值匹配。我想创建一个大的XML文件的记录的子集,使用小的一个。我的XSL的尝试是一样的东西叫“single_include.xml”这XSL基于xml记录的文件对一组记录进行子集化

<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文件是这样的

<ListOfOrganisationName> 
<OrganisationName> 
The first organisation 
</OrganisationName> 
<OrganisationName> 
The second organisation 
</OrganisationName> 
</ListOfOrganisationName> 

它似乎只对第一个记录工作。有任何想法吗?

希望这是有道理的。

+1

您可以包括(小)样本的大型XML,以及您的预期输出?谢谢! – 2012-07-25 11:51:20

+0

这个问题很含糊。请编辑*这个问题并提供一个* small * XMLDoc1(你称之为“大型XML文件”),并提供确切的想要的结果,同时解释转换的要求,不清楚你的意思是什么“记录的子集”以及“你匹配”的含义。 – 2012-07-25 12:00:22

回答

0

在你的“排斥”模板内谓词

(@OrganisationName!=document('single_include.xml')//OrganisationName) 

是真实的,如果有任何OrganisationNamesingle_include.xml不等于当前元素的OrganisationName属性。这将排除“第二个组织”,因为过滤文件(“第一个组织”)中存在一个不相等的OrganisationName。相反,你可能想

not(@OrganisationName=document('single_include.xml')//OrganisationName) 

只有在有这是真的没有OrganisationNamesingle_include.xml等于当前元素的OrganisationName属性。该XPath的规范使得section 3.4这一点上,它说的是

注:如果$x绑定到节点集,然后$x="foo"并不意味着一样not($x!="foo")