on 06-05-2019 4:24 PM
Hello everyone,
I am getting incoming payload as mentioned below.
Totally 4 records.. 2 records for (EmpID =123) and 2 records for (EmpID = 111)
<Root>
<EMPLOYEE> <EmpID>123</EmpID> <Name>Test1</Name> </EMPLOYEE>
<EMPLOYEE> <EmpID>123</EmpID> <Name>Test2</Name> </EMPLOYEE>
<EMPLOYEE> <EmpID>111</EmpID> <Name>Test3</Name> </EMPLOYEE>
<EMPLOYEE> <EmpID>111</EmpID> <Name>Test4</Name> </EMPLOYEE>
</Root>
I need unique values of "EmpID" field and avoid duplicates.
So my expectation is to get only EmpID value of "123" one time and "111" one time and remove other duplicate values.
Could anyone give me groovy script code to achieve it or any other alternative approach.?
Regards,
Deva
Hi Deveraj,
Use the below XSLT.
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<Root>
<xsl:for-each-group select="/Root/EMPLOYEE" group-by="EmpID">
<EMPLOYEE>
<EmpID>
<xsl:value-of select="EmpID"/>
</EmpID>
<Name>
<xsl:value-of select="Name"/>
</Name>
</EMPLOYEE>
</xsl:for-each-group>
</Root>
</xsl:template>
</xsl:stylesheet>
Regards,
Yatan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.