Is it possible to use XSLT to remove elements with duplicate values from an XML file?

Nicolás Lichtmaier

XSLT does not currently provide a direct way of extracting unique nodes from a nodeset but that feature can be emulated. The trick would be to ask at each node if there has been another one. This would work:

<xsl:template match="@*|node()">
  <xsl:if test="not(node()) or not(preceding-sibling::node()[.=string(current())])">
      <xsl:apply-templates select="@*|node()"/>

0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact