【发布时间】:2015-03-31 09:40:15
【问题描述】:
我正在尝试使用 XSLT 从 XML 文件中删除重复项。 输入是这样的:
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd>
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>UK</country>
<company>CBS Records</company>
<price>9.90</price>
<year>1988</year>
</cd>
<cd>
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>UK</country>
<company>CBS Records</company>
<price>9.90</price>
<year>1988</year>
</cd>
所需的输出是:
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd>
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>UK</country>
<company>CBS Records</company>
<price>9.90</price>
<year>1988</year>
</cd>
基本上我正在尝试删除重复记录。 我该怎么做?
【问题讨论】:
-
您使用 XSLT 1.0 还是 2.0?如果某些项目(例如,
title和artist)相同但其他项目不同(例如,price)会发生什么? -
我正在使用 XSLT 2.0。
-
目前我不考虑这种情况