0

大きな XML ファイルと、いくつかの大きな XML ファイルの属性値の 1 つに一致する名前を持つ別の小さな 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>

「single_include.xml」と呼ばれる私の小さな XML ファイルは次のようなものです

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

最初のレコードのみで機能するようです。何か案は?

これが理にかなっていることを願っています。

4

1 に答える 1

0

「除外」テンプレートの内部述語

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

現在の要素の属性と等しくない OrganisationNameものがある場合はtrueです。フィルタリングファイル(「最初の組織」)に等しくないが存在するため、これは「2番目の組織」を除外します。代わりに、あなたはおそらくしたいsingle_include.xmlOrganisationNameOrganisationName

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

これは、現在の要素の属性に等しいものがない OrganisationName場合にのみ当てはまります。XPath仕様では、セクション3.4でこの点を指摘しています。single_include.xmlOrganisationName

注:$xがノードセットにバインドされている場合は$x="foo"、と同じ意味ではありませんnot($x!="foo")

于 2012-07-25T12:26:21.980 に答える