我是XSLT的新手。输入文件下方的标记中包含重复值,我的要求是使用XSLT显示<Rip>
中<PGS>
的所有重复值。
<Rip>
是随机值,它将在另一个标记中重复。我们需要确定<RIP>
标记值与重复项匹配的位置。
如何使用XSLT仅显示重复的标记<PGS>
?
输入文件:
<?xml version="1.0" encoding="UTF-8"?>
<Rows>
<PGS>
<Rip>93S981371 </Rip>
<Settled>NO</Settled>
<MaturityDate>1/1/2025</MaturityDate>
<RemainingFace>105000000</RemainingFace>
<CurrentFace>0</CurrentFace>
</PGS>
<PGS>
<Rip>02R030483 </Rip>
<Settled>YES</Settled>
<MaturityDate>9/8/2025</MaturityDate>
<Remaining-Face>285000000</RemainingFace>
<CurrentFace>0</CurrentFace>
</PGS>
<PGS>
<Rip>77344444 </Rip>
<Settled>YES</Settled>
<MaturityDate>9/8/2025</MaturityDate>
<Remaining-Face>285000000</RemainingFace>
<CurrentFace>0</CurrentFace>
</PGS>
<PGS>
<Rip>02R030483 </Rip>
<Settled>NO</Settled>
<MaturityDate>9/8/2025</MaturityDate>
<Remaining-Face>285000000</RemainingFace>
<CurrentFace>0</CurrentFace>
</PGS>
<PGS>
<Rip>93S981371 </Rip>
<Settled>YES</Settled>
<MaturityDate>1/1/2025</MaturityDate>
<Remaining-Face>405000000</RemainingFace>
<CurrentFace>0</CurrentFace>
</PGS>
</Rows>
预期的输出文件:
<?xml version="1.0"?>
<Rows>
<PGS>
<Rip>93S981371 </Rip>
<Settled>NO</Settled>
<MaturityDate>1/1/2025</MaturityDate>
<RemainingFace>105000000</RemainingFace>
<CurrentFace>0</CurrentFace>
</PGS>
<PGS>
<Rip>93S981371 </Rip>
<Settled>YES</Settled>
<MaturityDate>1/1/2025</MaturityDate>
<Remaining-Face>405000000</RemainingFace>
<CurrentFace>0</CurrentFace>
</PGS>
<PGS>
<Rip>02R030483 </Rip>
<Settled>YES</Settled>
<MaturityDate>9/8/2025</MaturityDate>
<Remaining-Face>285000000</RemainingFace>
<CurrentFace>0</CurrentFace>
</PGS>
</PGS>
<Rip>02R030483 </Rip>
<Settled>NO</Settled>
<MaturityDate>9/8/2025</MaturityDate>
<Remaining-Face>285000000</RemainingFace>
<CurrentFace>0</CurrentFace>
</PGS>
答案 0 :(得分:0)
你的问题的答案是:
首先定义一个密钥,用PGS
标识Rip
,例如
<xsl:key name="pgs" match="PGS" use="Rip" />
然后匹配(或复制)具有多个“相关”值的PGS
元素:
PGS[count(key('pgs', Rip)) > 1]
即。它们与另一个PGS
元素相匹配。