我有一个 filter.xsl,我将它与我的输入 xml 一起使用,我得到了重复的输出。我需要删除输出中的重复项。你能看看这个,让我知道我需要改变哪里吗?
这是 XSLT
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns="http://www.gazettes.co.uk/assets/taxonomy"
xmlns:tax="http://www.gazettes.co.uk/assets/taxonomy"
xmlns:cc="http://www.tso.co.uk/assets/namespace/gazette/config"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" exclude-result-prefixes="#all">
<xsl:param name="privileges" as="node()" select="doc('privileges.xml')"/>
<xsl:output encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<notice-taxonomy>
<xsl:apply-templates/>
<xsl:if test="not(exists(/*[local-name() = 'notice-taxonomy']/*[local-name() = 'notice-type'][@level='category']))">
<xsl:apply-templates select="*[local-name() = 'notice-type'][@level='section']" mode="copy"/>
</xsl:if>
</notice-taxonomy>
</xsl:template>
<xsl:template match="*[local-name() = 'notice-type'][@level='category']">
<xsl:variable name="tree" select="."/>
<xsl:for-each select="$privileges//privilege">
<xsl:variable name="code" select="substring-after(.,':')"/>
<!-- <xsl:variable name="HHH"><xsl:sequence select="$code"/></xsl:variable> -->
<xsl:if test="$code != ''">
<xsl:if test="$tree//*[@code = $code]">
<xsl:element name="notice-type">
<xsl:copy-of select="$tree/@*"/>
<xsl:apply-templates select="$tree" mode="copy"/>
</xsl:element>
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template match="*[local-name() = 'notice-type'][@level='section']" mode="copy">
<xsl:variable name="this" select="."/>
<xsl:variable name="localcode" select="@code"/>
<xsl:for-each select="$privileges//privilege">
<xsl:variable name="pcode" select="substring-after(.,':')"/>
<xsl:if test="$this//*[local-name() = 'notice-type'][@code = $pcode]">
<xsl:element name="notice-type">
<xsl:copy-of select="$this/@*"/>
<xsl:apply-templates select="$this/*" mode="copy"/>
</xsl:element>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template match="*[local-name() = 'notice-type'][@level='notice']" mode="copy">
<xsl:variable name="this" select="."/>
<xsl:variable name="localcode" select="@code"/>
<xsl:for-each select="$privileges//privilege">
<xsl:variable name="pcode" select="substring-after(.,':')"/>
<xsl:if test="$localcode = $pcode">
<xsl:element name="notice-type">
<xsl:copy-of select="$this/@*"/>
</xsl:element>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
输出是
<?xml version="1.0" encoding="UTF-8"?>
<notice-taxonomy xmlns="http://www.gazettes.co.uk/assets/taxonomy">
<notice-type name="State" code="11" service-key="all-notices" level="category" sort="01"
popular="true">
<notice-type name="Proclamations" code="1101" level="notice" sort="01"/>
</notice-type>
`<notice-type name="Corporate Insolvency" code="24" service-key="insolvency" level="category"
sort="15"
popular="true">
<notice-type name="General" code="2400/0" level="section" sort="01">
<notice-type name="Moratoria, Prohibited Names and Other: Moratorium: Coming to an End"
code="2402"
level="notice"
sort="02"/>
<notice-type name="Court Petitions and Orders: Cross-border Insolvencies" code="2404"
level="notice"
sort="04"/>
</notice-type>
<notice-type name="General" code="2400/0" level="section" sort="01">
<notice-type name="Moratoria, Prohibited Names and Other: Moratorium: Coming to an End"
code="2402"
level="notice"
sort="02"/>
<notice-type name="Court Petitions and Orders: Cross-border Insolvencies" code="2404"
level="notice"
sort="04"/>
</notice-type>
<notice-type name="Administration" code="2400/1" level="section" sort="02">
<notice-type name="Notices to Members" code="2413" level="notice" sort="13"/>
</notice-type>
</notice-type>
<notice-type name="Corporate Insolvency" code="24" service-key="insolvency" level="category"
sort="15"
popular="true">
<notice-type name="General" code="2400/0" level="section" sort="01">
<notice-type name="Moratoria, Prohibited Names and Other: Moratorium: Coming to an End"
code="2402"
level="notice"
sort="02"/>
<notice-type name="Court Petitions and Orders: Cross-border Insolvencies" code="2404"
level="notice"
sort="04"/>
</notice-type>
<notice-type name="General" code="2400/0" level="section" sort="01">
<notice-type name="Moratoria, Prohibited Names and Other: Moratorium: Coming to an End"
code="2402"
level="notice"
sort="02"/>
<notice-type name="Court Petitions and Orders: Cross-border Insolvencies" code="2404"
level="notice"
sort="04"/>
</notice-type>
<notice-type name="Administration" code="2400/1" level="section" sort="02">
<notice-type name="Notices to Members" code="2413" level="notice" sort="13"/>
</notice-type>
</notice-type>
<notice-type name="Corporate Insolvency" code="24" service-key="insolvency" level="category"
sort="15"
popular="true">
<notice-type name="General" code="2400/0" level="section" sort="01">
<notice-type name="Moratoria, Prohibited Names and Other: Moratorium: Coming to an End"
code="2402"
level="notice"
sort="02"/>
<notice-type name="Court Petitions and Orders: Cross-border Insolvencies" code="2404"
level="notice"
sort="04"/>
</notice-type>
<notice-type name="General" code="2400/0" level="section" sort="01">
<notice-type name="Moratoria, Prohibited Names and Other: Moratorium: Coming to an End"
code="2402"
level="notice"
sort="02"/>
<notice-type name="Court Petitions and Orders: Cross-border Insolvencies" code="2404"
level="notice"
sort="04"/>
</notice-type>
<notice-type name="Administration" code="2400/1" level="section" sort="02">
<notice-type name="Notices to Members" code="2413" level="notice" sort="13"/>
</notice-type>
</notice-type>`
<notice-type name="Personal Insolvency" code="25" service-key="insolvency" level="category"
sort="16"
popular="true">
<notice-type name="Statutory Demands" code="2501" level="notice" sort="01"/>
<notice-type name="Administration Order" code="2505" level="notice" sort="05"/>
</notice-type>
<notice-type name="Personal Insolvency" code="25" service-key="insolvency" level="category"
sort="16"
popular="true">
<notice-type name="Statutory Demands" code="2501" level="notice" sort="01"/>
<notice-type name="Administration Order" code="2505" level="notice" sort="05"/>
</notice-type>
<notice-type name="Societies Regulation" code="28" service-key="all-notices"
level="category"
sort="19">
<notice-type name="Building Societies" code="2803" level="notice" sort="03"/>
</notice-type>
<notice-type name="Personal Legal" code="29" service-key="wills-and-probate"
level="category"
sort="20"
popular="true">
<notice-type name="Deceased Estates" code="2903" level="notice" sort="03"/>
</notice-type>
<notice-type name="Contributors Information" code="99" service-key="all-notices"
level="category"
sort="0">
<notice-type name="Contributors Information" code="9900" level="notice" sort="01"/>
</notice-type>
</notice-taxonomy>
这应该是
<?xml version="1.0" encoding="UTF-8"?>
<notice-taxonomy xmlns="http://www.gazettes.co.uk/assets/taxonomy">
<notice-type name="State" code="11" service-key="all-notices" level="category" sort="01"
popular="true">
<notice-type name="Proclamations" code="1101" level="notice" sort="01"/>
</notice-type>
<notice-type name="Corporate Insolvency" code="24" service-key="insolvency" level="category"
sort="15"
popular="true">
<notice-type name="General" code="2400/0" level="section" sort="01">
<notice-type name="Moratoria, Prohibited Names and Other: Moratorium: Coming to an End"
code="2402"
level="notice"
sort="02"/>
<notice-type name="Court Petitions and Orders: Cross-border Insolvencies" code="2404"
level="notice"
sort="04"/>
</notice-type>
<notice-type name="General" code="2400/0" level="section" sort="01">
<notice-type name="Moratoria, Prohibited Names and Other: Moratorium: Coming to an End"
code="2402"
level="notice"
sort="02"/>
<notice-type name="Court Petitions and Orders: Cross-border Insolvencies" code="2404"
level="notice"
sort="04"/>
</notice-type>
<notice-type name="Administration" code="2400/1" level="section" sort="02">
<notice-type name="Notices to Members" code="2413" level="notice" sort="13"/>
</notice-type>
</notice-type>
<notice-type name="Personal Insolvency" code="25" service-key="insolvency" level="category"
sort="16"
popular="true">
<notice-type name="Statutory Demands" code="2501" level="notice" sort="01"/>
<notice-type name="Administration Order" code="2505" level="notice" sort="05"/>
</notice-type>
<notice-type name="Personal Insolvency" code="25" service-key="insolvency" level="category"
sort="16"
popular="true">
<notice-type name="Statutory Demands" code="2501" level="notice" sort="01"/>
<notice-type name="Administration Order" code="2505" level="notice" sort="05"/>
</notice-type>
<notice-type name="Societies Regulation" code="28" service-key="all-notices"
level="category"
sort="19">
<notice-type name="Building Societies" code="2803" level="notice" sort="03"/>
</notice-type>
<notice-type name="Personal Legal" code="29" service-key="wills-and-probate"
level="category"
sort="20"
popular="true">
<notice-type name="Deceased Estates" code="2903" level="notice" sort="03"/>
</notice-type>
<notice-type name="Contributors Information" code="99" service-key="all-notices"
level="category"
sort="0">
<notice-type name="Contributors Information" code="9900" level="notice" sort="01"/>
</notice-type>
</notice-taxonomy>
和参数 preveliges.xml
<privileges>
<privilege>Access my notices</privilege>
<privilege>Access draft notices</privilege>
<privilege>Place notice</privilege>
<privilege>Access published notices</privilege>
<privilege>Place notice of type:2903</privilege>
<privilege>Place notice of type:2413</privilege>
<privilege>Place notice of type:2803</privilege>
<privilege>Access pending notices</privilege>
<privilege>Access my account</privilege>
<privilege>Place legacy notice</privilege>
<privilege>Access my searches</privilege>
<privilege>Place notice of type:1101</privilege>
<privilege>Place notice of type:2404</privilege>
<privilege>Place notice of type:2402</privilege>
<privilege>Place notice of type:2501</privilege>
<privilege>Place notice of type:2505</privilege>
<privilege>Place notice of type:9900</privilege>
</privileges>
任何帮助,请