我陷入了 XSLT 程序,该程序消除了输出中的重复项。感谢帮助
XML 输入:
<changelog>
<entry>
<file>
<name>web/JavaSource/oig/asoig/web/resource/AsoigResources.properties</name>
<revision>1.7.2.6</revision>
<prevrevision>1.7.2.5</prevrevision>
</file>
</entry>
<entry>
<file>
<name>AdminEJB/ejbModule/oig/admin/dao/schema/TableCode.java</name>
<revision>1.1.4.2</revision>
<prevrevision>1.1.4.1</prevrevision>
</file>
<file>
<name>web/JavaSource/oig/asoig/web/resource/AsoigResources.properties</name>
<revision>1.7.2.6</revision>
<prevrevision>1.7.2.5</prevrevision>
</file>
</entry>
</changelog>
期望的输出:
web/JavaSource/oig/asoig/web/resource/AsoigResources.properties
AdminEJB/ejbModule/oig/admin/dao/schema/TableCode.java
注意:AsoigResources.properties 在输入 XML 中重复。
使用的 XSLT 代码:
<xsl:for-each select="entry/file">
<tr>
<td><xsl:value-of select="name"/></td>
</tr>
</xsl:for-each>
我需要 XSLT 来删除重复项。我尝试使用“以下 sibling ”,但没有帮助。
最佳答案
您可以对 xsl:for-each
使用以下 XPath 表达式:
entry/file[not(name = preceding::name)]
选择名称与任何前面的名称都不匹配的文件。
关于xslt - 消除 XSLT 中的重复文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20666404/