0
votes

I have a requirement like this, Under the root tag 'Features' multiple feature elements are present.I need to remove duplicates. I have loaded its corresponding xsd in both source and target. But was not sure how to remove duplicates. My xml is a complex one, but to understand, I made here as simple.

Source ( input xml)

<features>
  ......(other fields)...
 <Datas>
   <feature> 1</feature>
   <feature> 2 </feature>
   <feature> 1 </feature>
   <feature> 3 </feature>
   <feature> 3 </feature>
  </Datas>  
</features> 

Target ( output xml)

<features>
   ....(other fields)....
  <ItemDetails>
   <feature> 1</feature>
   <feature> 2 </feature>
   <feature> 3 </feature> 
 </ItemDetails>

I was thinking, something need to do in For each element in DataMapper. But not sure how can be done or may be it is wrong

Please let me know if any short cut, crispy way to remove the duplicates. It will reduce my time in large. Mule version: 3.5.1 Thanks in advance.

2

2 Answers

1
votes

This cannot be accomplished with DataMapper, you need an ulterior XSLT transformer to remove duplicates, see the following stackoverflow question.

0
votes

I have resolved the problem in this way.

First I used Datamapper. It will gives as response but with duplicates. Finally I used Simple XSLT as described in this link Removing duplicate elements with XSLT( It removes duplicates alone) and make copy of remaining transformed field as such ( I used XSLT v1 in the link)

Hope It might helps for those facing the problem like me.