I need to remove duplicates in the following xml:
You need to group them together using the Muenchian grouping method. Or the more specific grouping functions in xslt 2.0. Here are two relevant stack overflow questions:
How to use group by in xslt
How to output duplicate elements using XSLT?