首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从xsl中排除结果

从xsl中排除结果
EN

Stack Overflow用户
提问于 2017-06-24 17:20:25
回答 1查看 104关注 0票数 0

这段代码来自我发送的一个附加的xsl,当我告诉我的客户端,配置文件错误地排除了标题中带有“北爱尔兰”的内容。现在,他把一切都带回来了,但是我需要排除一些结果--下面的一个例子。

我想从结果中筛选出的对象的标识信息是nisr in affectingURI,例如键-33793274a92a1f194b3ebcfccfc08927。

我怎样才能摆脱这些“nisr”的结果?

代码语言:javascript
复制
<xsl:template match="atom:feed" mode="results">
    <xsl:apply-templates select="atom:entry/ukm:Effect"/>
</xsl:template>
<xsl:template match="ukm:Effect">
    <xsl:choose>
        <xsl:when test="@Type= 'Commencement Order' and @AffectedProvisions='specified amended provision(s)'"/>
        <xsl:when test="contains(ukm:AffectingTitle[1], 'Northern Ireland')"/>
        <xsl:when test="contains(ukm:AffectingTitle[1], 'Northern-Ireland')"/>
        <xsl:when test="contains(ukm:AffectedTitle[1], 'Northern Ireland')"/>
        <xsl:when test="contains(ukm:AffectedTitle[1], 'Northern-Ireland')"/>
        <xsl:when test="@Type= 'coming into force'"/>
        <xsl:otherwise>
            <tr xsl:exclude-result-prefixes="atom xs xhtml tso db sls ukm">
                <xsl:apply-templates select="." mode="resultsAffectedYearNumber"/>
                <xsl:apply-templates select="." mode="resultsAffectedTitle"/>
                <xsl:apply-templates select="." mode="resultsChangedProvision"/>
                <xsl:apply-templates select="." mode="resultsAffectingTitle"/>
                <xsl:apply-templates select="." mode="resultsInForceDates"/>
                <xsl:apply-templates select="." mode="resultsEffectId"/>
            </tr>
        </xsl:otherwise>
    </xsl:choose>

这是消息来源。

-我希望我的结果中没有"key-33793274a92a1f194b3ebcfccfc08927“,因为它包含NISR。

-If您可以帮助我排除NISR,我将采用相同的逻辑,并将其应用于“key-e789d8a9e46169ba1f49655051c66d1”,因为affectingURI中的NIA也是我需要省略的六个句柄之一。

-The UK pga (英国公共和一般行为,对于那些想知道自己在看什么的人来说!)结果("key-fce2f92caeab329b0d33dfb1adca9bdf")将包括在内。在替换配置之前,我的出发点是缺少这个,因为它的标题中有北爱尔兰,而且在一些我无法识别的地方,它被错误地排除在外。提交人只应排除NIA、NISR、NISI。

代码语言:javascript
复制
<entry>
                            <id>http://www.legislation.gov.uk/changes/affected/ukpga/1972/18/affecting/nisr/2016/387/modified/2017-01-19T15:31:27Z</id>
                            <title>The Justice (2015 Act) (Commencement No. 7 and Saving Provisions) Order (Northern Ireland) 2016 effect on Maintenance Orders (Reciprocal Enforcement) Act 1972</title>
                            <updated>2017-01-19T15:31:27Z</updated>
                            <author><name/></author>
                            <ukm:Effect EffectId="key-33793274a92a1f194b3ebcfccfc08927" AffectedClass="UnitedKingdomPublicGeneralAct" AffectedURI="http://www.legislation.gov.uk/id/ukpga/1972/18" AffectingURI="http://www.legislation.gov.uk/id/nisr/2016/387" AffectingClass="NorthernIrelandStatutoryRule" URI="http://www.legislation.gov.uk/id/effect/key-33793274a92a1f194b3ebcfccfc08927" Row="70" Type="Commencement Order" Applied="false" RequiresApplied="true" AffectedProvisions="specified amended provision(s)" Notes="commencement order for 2015 c. 9 (N.I.)" AffectingYear="2016" AffectingNumber="387" AffectingProvisions="art. 2" AffectedYear="1972" AffectedNumber="18" Modified="2017-01-19T15:31:27Z"><ukm:AffectedTitle>Maintenance Orders (Reciprocal Enforcement) Act 1972</ukm:AffectedTitle><ukm:AffectedProvisions>specified amended provision(s)</ukm:AffectedProvisions><ukm:AffectingTitle>The Justice (2015 Act) (Commencement No. 7 and Saving Provisions) Order (Northern Ireland) 2016</ukm:AffectingTitle><ukm:AffectingProvisions><ukm:Section Ref="article-2" URI="http://www.legislation.gov.uk/id/nisr/2016/387/article/2">art. 2</ukm:Section></ukm:AffectingProvisions><ukm:Commenced>commencement order for <ukm:Citation Class="NorthernIrelandAct" URI="http://www.legislation.gov.uk/id/nia/2015/9" Year="2015" Number="9" Title="Justice Act (Northern Ireland) 2015">2015 c. 9 (N.I.)</ukm:Citation></ukm:Commenced><ukm:InForceDates><ukm:InForce Applied="false" Prospective="true" Qualification=""/></ukm:InForceDates></ukm:Effect>
                        </entry><entry>
                            <id>http://www.legislation.gov.uk/changes/affected/ukpga/1973/36/affecting/nia/2016/4/modified/2016-03-25T09:47:14Z</id>
                            <title>Public Services Ombudsman Act (Northern Ireland) 2016 effect on Northern Ireland Constitution Act 1973</title>
                            <updated>2016-03-25T09:47:14Z</updated>
                            <author><name/></author>
                            <ukm:Effect EffectId="key-e789d8aa9e46169ba1f49655051c66d1" AffectedURI="http://www.legislation.gov.uk/id/ukpga/1973/36" AffectedClass="UnitedKingdomPublicGeneralAct" AffectingURI="http://www.legislation.gov.uk/id/nia/2016/4" AffectingClass="NorthernIrelandAct" URI="http://www.legislation.gov.uk/id/effect/nia-2016-4-4ds9a6o2-90" Row="90" Type="repealed" Applied="false" RequiresApplied="true" AffectedProvisions="s. 36(1)(a)(b)" AffectingEffectsExtent="NI" AffectingYear="2016" AffectingNumber="4" AffectingProvisions="Sch. 9" AffectedYear="1973" AffectedNumber="36" Created="2016-03-25T09:47:14Z" Modified="2016-03-25T09:47:14Z"><ukm:AffectedTitle>Northern Ireland Constitution Act 1973</ukm:AffectedTitle><ukm:AffectedProvisions><ukm:Section Ref="section-36-1-a" URI="http://www.legislation.gov.uk/id/ukpga/1973/36/section/36/1/a">s. 36(1)(a)</ukm:Section><ukm:Section Ref="section-36-1-b" URI="http://www.legislation.gov.uk/id/ukpga/1973/36/section/36/1/b">(b)</ukm:Section></ukm:AffectedProvisions><ukm:AffectingTitle>Public Services Ombudsman Act (Northern Ireland) 2016</ukm:AffectingTitle><ukm:AffectingTitle>Public Services Ombudsman Act (Northern Ireland) 2016</ukm:AffectingTitle><ukm:AffectingProvisions><ukm:Section Ref="schedule-9" URI="http://www.legislation.gov.uk/id/nia/2016/4/schedule/9">Sch. 9</ukm:Section></ukm:AffectingProvisions><ukm:CommencementAuthority><ukm:Section Ref="section-64" URI="http://www.legislation.gov.uk/id/nia/2016/4/section/64">s. 64</ukm:Section></ukm:CommencementAuthority><ukm:InForceDates><ukm:InForce Applied="false" Date="2016-04-01" Qualification="wholly in force"/></ukm:InForceDates></ukm:Effect>
                        </entry><entry>
                            <id>http://www.legislation.gov.uk/changes/affected/ukpga/1974/37/affecting/ukpga/2016/25/modified/2017-04-10T10:13:36Z</id>
                            <title>Investigatory Powers Act 2016 effect on Health and Safety at Work etc. Act 1974</title>
                            <updated>2017-04-10T10:13:36Z</updated>
                            <author><name/></author>
                            <ukm:Effect EffectId="key-fce2f92caeab329b0d33dfb1adca9bdf" AffectedClass="UnitedKingdomPublicGeneralAct" AffectedURI="http://www.legislation.gov.uk/id/ukpga/1974/37" AffectingURI="http://www.legislation.gov.uk/id/ukpga/2016/25" AffectingClass="UnitedKingdomPublicGeneralAct" URI="http://www.legislation.gov.uk/id/effect/key-fce2f92caeab329b0d33dfb1adca9bdf" Row="10" Type="inserted" Applied="false" RequiresApplied="true" AffectedProvisions="s. 20(9)(10)" AffectingEffectsExtent="E+W+S+N.I." AffectingYear="2016" AffectingNumber="25" AffectingProvisions="Sch. 2 para. 1" AffectedYear="1974" AffectedNumber="37" Modified="2017-04-10T10:13:36Z"><ukm:AffectedTitle>Health and Safety at Work etc. Act 1974</ukm:AffectedTitle><ukm:AffectedProvisions><ukm:Section Ref="section-20-9" URI="http://www.legislation.gov.uk/id/ukpga/1974/37/section/20/9" FoundRef="section-20">s. 20(9)</ukm:Section><ukm:Section Ref="section-20-10" URI="http://www.legislation.gov.uk/id/ukpga/1974/37/section/20/10" FoundRef="section-20">(10)</ukm:Section></ukm:AffectedProvisions><ukm:AffectingTitle>Investigatory Powers Act 2016</ukm:AffectingTitle><ukm:AffectingTitle>Further Education) Order (Northern Ireland) 2016</ukm:AffectingTitle><ukm:AffectingProvisions><ukm:Section Ref="schedule-2" URI="http://www.legislation.gov.uk/id/ukpga/2016/25/schedule/2">Sch. 2 </ukm:Section><ukm:Section Ref="schedule-2-paragraph-1" URI="http://www.legislation.gov.uk/id/ukpga/2016/25/schedule/2/paragraph/1">para. 1</ukm:Section></ukm:AffectingProvisions><ukm:Savings><ukm:Section Ref="schedule-9" URI="http://www.legislation.gov.uk/id/ukpga/2016/25/schedule/9">Sch. 9 </ukm:Section><ukm:Section Ref="schedule-9-paragraph-7" URI="http://www.legislation.gov.uk/id/ukpga/2016/25/schedule/9/paragraph/7">paras. 7</ukm:Section> <ukm:Section Ref="schedule-9-paragraph-8" URI="http://www.legislation.gov.uk/id/ukpga/2016/25/schedule/9/paragraph/8">8</ukm:Section> <ukm:Section Ref="schedule-9-paragraph-10" URI="http://www.legislation.gov.uk/id/ukpga/2016/25/schedule/9/paragraph/10">10</ukm:Section></ukm:Savings><ukm:CommencementAuthority><ukm:Section Ref="section-272-1" URI="http://www.legislation.gov.uk/id/ukpga/2016/25/section/272/1">s. 272(1)</ukm:Section></ukm:CommencementAuthority><ukm:InForceDates><ukm:InForce Applied="false" Prospective="true" Qualification=""/></ukm:InForceDates></ukm:Effect>
                        </entry>
EN

回答 1

Stack Overflow用户

发布于 2017-06-26 12:19:44

我不确定我是否完全理解这个问题,但是当你说“我想过滤掉affectingURI中的结果是nisr”时,解决这个问题的一种方法就是使用模板匹配来排除问题。

当前有一个匹配ukm:Effect的模板,它与所有这样的命名元素匹配。

代码语言:javascript
复制
<xsl:template match="ukm:Effect">

如果您有一个规则,ukm:Effect元素将被排除在nisr位于affectingURI中的位置,那么您应该添加另一个模板,如下所示

代码语言:javascript
复制
<xsl:template match="ukm:Effect[contains(@AffectingURI, '/nisr/')]" />

因为该模板在元素名称之后有一个条件,因此它将比其他模板具有更高的优先级,从而导致该ukm:Effect元素被排除在外。

所以,与其使用xsl:choose / xsl:when来排除元素.

代码语言:javascript
复制
<xsl:when test="contains(ukm:AffectingTitle[1], 'Northern Ireland')"/>

您可以将其重写为模板匹配以排除它。

代码语言:javascript
复制
<xsl:template match="ukm:Effect[contains(ukm:AffectingTitle[1], 'Northern Ireland')]"/>

但是要小心,匹配ukm:Effect[contains(ukm:AffectingTitle[1], 'Northern Ireland')]的模板与匹配ukm:Effect[contains(@AffectingURI, '/nisr')]的模板具有相同的优先级(因为两者都有条件)。如果两个模板可以以相同的优先级匹配相同的元素,则认为这是一个错误。在本例中,您可能需要在第二个模板上添加一个priority属性。

代码语言:javascript
复制
<xsl:template match="ukm:Effect[contains(@AffectingURI, '/nisr')]" priority="2" />

或者,您可以使用一个大的条件检查模板。

代码语言:javascript
复制
<xsl:template match="ukm:Effect[contains(@AffectingURI, '/nisr/') or contains(ukm:AffectingTitle[1], 'Northern Ireland')]"/>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44739022

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档