以下是一个例子,我想在ID相同时删除重复的记录。 我正在从系统“A”和系统“B”中获取数据。 我希望系统“A”具有优先权(即,如果ID重复,则从系统“B”中删除该元素)。这是我的示例:
我得到了这个结果:
<HitList>
<Hit System="A" ID="1"/>
<Hit System="A" ID="2"/>
<Hit System="A" ID="2"/>
<Hit System="B" ID="1"/>
<Hit System="B" ID="2"/>
<Hit System="B" ID="3"/>
<Hit System="B" ID="4"/>
</HitList>
I want this result (with the duplicates removed):
<HitList>
<Hit System="A" ID="1"/>
<Hit System="A" ID="2"/>
<Hit System="B" ID="3"/>
<Hit System="B" ID="4"/>
</HitList>
当前代码:
<xsl:template match="/RetrievePersonSearchDataRequest">
<HitList>
<xsl:if test="string(RetrievePersonSearchDataRequest/SystemA/NamecheckResponse/@Status) = string(Succeeded)">
<xsl:for-each select="SystemA/NamecheckResponse/BATCH/ITEMLIST/ITEM/VISQST/NCHITLIST/NCHIT">
<Hit>
<xsl:attribute name="System"><xsl:text>A</xsl:text></xsl:attribute>
<xsl:attribute name="PersonID"><xsl:value-of select="number(
REFUSAL/@UID)"/></xsl:attribute>
</Hit>
</xsl:for-each>
</xsl:if>
<xsl:if test="string(RetrievePersonSearchDataRequest/SystemB/NamecheckResponse/@Status) = string(Succeeded)">
<xsl:for-each select="SystemB/NamecheckResponse/PersonIDSearchResponse/personID">
<Hit>
<xsl:attribute name="System"><xsl:text>B</xsl:text></xsl:attribute>
<xsl:attribute name="PersonID"><xsl:value-of select="number(.)"/></xsl:attribute>
</Hit>
</xsl:for-each>
</xsl:if>
</HitList>
</xsl:template>