on 04-04-2023 1:09 PM
Hi All,
We have requirement of removing the duplicate records based on email. In email, we might have different type of text like, sometimes all values in caps or sometimes all values in small or sometimes first letter caps and remaining values in small like that. So, to compare the duplicate values, we need to convert the values either to small or caps just for duplicate comparison.
Previously, We have removed the duplicates with Employee ID. So, I have used below XSLT mapping.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="root">
<root>
<xsl:for-each-group select="USER"
group-by="EmployeeID">
<xsl:apply-templates select="."/>
</xsl:for-each-group>
</root>
</xsl:template>
</xsl:stylesheet>
Currently, I might get the emails like below.michel.hari@xyz.comMichel.HARI@xyz.com
Source payload might look like below and taget also need same structure<root> <USER> <EmployeeID>1234</EmployeeID> <email>michel.hari@xyz.com</email> </USER></root>
So please help me in figuring out a way to remove the duplicates records of this user considering both records have same data excepts the caps and small letters.
Hi Mohanty,
Can you please try below one.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="root">
<root>
<xsl:for-each-group select="USER" group-by="lower-case(email)">
<xsl:apply-templates select="."/>
</xsl:for-each-group>
</root>
</xsl:template>
</xsl:stylesheet>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks So much, Anoop.
It worked for me.
User | Count |
---|---|
73 | |
8 | |
8 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.