wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes removing duplicate elements Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "removing duplicate elements" Watch "removing duplicate elements" New topic

removing duplicate elements

Vijay Chouhan
Ranch Hand

Joined: Sep 01, 2005
Posts: 30
Hi Ranchers,

I have some XML data of the following structure.

Now I need to process this data using XSL and ensure that the duplicate elements are output only once. Also the order of the elements should not be changed. The output for the above should look like.

Try as I hard I can, I am not able to make any headway. Will really appreciate any leads.

Radha Voodi

Joined: Jun 06, 2007
Posts: 1
Try this:

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

Vijay Chouhan
Ranch Hand

Joined: Sep 01, 2005
Posts: 30
Hey thanks a ton Radha.. You've solved my problem.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: removing duplicate elements
Similar Threads
Any Suggestion about a small project?
Use of of a Comparable object as a parameter to indexof
Stateless EJB seems Stateful in action!
Whether to go to US or UK: Need Advice
Cannot Collections.binarySearch() a collection that implements Comparable.