2012-07-25 151 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")