2017-06-24 6 views
0

このコードは、設定ファイルがタイトルの「北アイルランド」のものを間違って除外していることをクライアントに伝えたときに送信された補足xslに由来します。さて、彼はそれをすべて取り戻しましたが、私はいくつかの結果を除外する必要があります - 例を以下に示します。xslから結果を除外する

Iは、結果のフィルタリングしたいオブジェクトの識別情報は、終了時にポストされたXMLでnisr内部affectingURI e.g.key-33793274a92a1f194b3ebcfccfc08927あります。

これらの「nisr」の結果をどのように取り除くことができますか?

<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> 

ここにソースがあります。

- 「キー-33793274a92a1f194b3ebcfccfc08927」については、NISRが含まれているため、私の結果には何も持たないことを望みます。あなたは私がNISRを除外することができます-IF

、私は同じロジックを取り、それを適用します「キーe789d8aa9e46169ba1f49655051c66d1」にもaffectingURIでNIAは、私が

-The英国を省略する必要がある6つのハンドルの一つであるため、 pga(彼らが何を見ているか知りたい人のために、英国の公的行為と一般行為)の結果( "key-fce2f92caeab329b0d33dfb1adca9bdf")が含まれます。置き換え設定の前の私の出発点は、タイトルに北アイルランドがあり、どこかで私が特定できない場所であるため、これは間違って除外されていたということでした。著者は、NIA、NISR、NISIのみを除外すべきである。

<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> 
+0

することができ、また

<xsl:template match="ukm:Effect[contains(@AffectingURI, '/nisr')]" priority="2" /> 

この場合、第2のテンプレートにpriority属性を固執する必要がある場合があります。入力と予想される出力を含む再現可能な例を投稿してください - [mcve]を参照してください。 –

+0

この質問を削除し、コードのセクション全体を投稿します。ありがとうございました。 – mynameisred

+0

ああ、別の半時間のために投稿することはできません... – mynameisred

答えて

0

私は、この問題を解決するための一つのアプローチは、テンプレートマッチングを利用している私は完全に質問を理解してかどうかわからないけど、あなたが言うとき、「私は結果をフィルタリングしたいaffectingURI内nisrです」物事を排除する。

あなたが現在あなたがukm:Effect要素がnisrがaffectingURIの内側にある場合、あなたはあなたがそうのような別のテンプレートを追加する必要が除外されるルールを持っている場合は、すべてのそのような名前の要素

<xsl:template match="ukm:Effect"> 

に一致するukm:Effectテンプレートマッチングを持っています

<xsl:template match="ukm:Effect[contains(@AffectingURI, '/nisr/')]" /> 

このテンプレートは、その後、要素名の後に条件を持っているので、それがされているukm:Effect要素で、その結果、他のテンプレートという高い優先順位を持つことになります除外される。

だから、代わりに...の要素を除外する

<xsl:when test="contains(ukm:AffectingTitle[1], 'Northern Ireland')"/> 

xsl:choose/xsl:whenを持つのあなたは、しかし、テンプレート警戒してください

<xsl:template match="ukm:Effect[contains(ukm:AffectingTitle[1], 'Northern Ireland')]"/> 

それを除外するためのテンプレートマッチとしてこれを書き換えることができukm:Effect[contains(ukm:AffectingTitle[1], 'Northern Ireland')]の一致は、ukm:Effect[contains(@AffectingURI, '/nisr')]に一致するテンプレートと同じ優先度を持ちます(両方とも条件があるため)。 2つのテンプレートが同じ要素に同じ優先度で一致する場合は、エラーとみなされます。あなたは、あなたの質問は明らかではないが、あなたは大きな条件のチェックと1つのテンプレート、

<xsl:template match="ukm:Effect[contains(@AffectingURI, '/nisr/') or contains(ukm:AffectingTitle[1], 'Northern Ireland')]"/> 
+0

すべて本当に役に立った、ありがとうございます。私はバッシュを持っていきます。すべてのものが走るのに1時間ほどかかるので、私が周りを遊んでいる間、私は静かに行きます。私が確信している唯一のことは、nisrを除外したいということです。あなたの疑問にお答えしていないのではないでしょうか?あなたの助けになる助言は、xslにnisrを含めるように頼んでいると思いますか?再度 – mynameisred

+0

'@AffectingURI'に'/nisr/'が含まれている場合、テンプレート'

+0

ありがとうあなたの助けを借りて私は、あなたのコメントが意味をなさないものの、私の知識を増やしても、私の問題は解決されないので、私はクライアントに戻って、彼らが間違っているものを是正するのを待つことになると思います。再度、感謝します。 – mynameisred

関連する問題