cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping: Removing single rows, leaving duplicates

robert_warde4
Active Participant
0 Kudos

Hi,

I have a particular problem. I have an input file that contains groups of records. There should be two records for each vendor. However, some have just one. What I want to do is exclude those vendors that only have one records

INPUT

VENDOR #
TYPE
NAME
123456AXXXXX
123456BYYYYY
908976BGGGGG
334567AGGGGG
334567AGGGFD
123321BFDSSSS

OUTPUT

VENDOR #TYPENAME
123456AXXXXX
123456BYYYYY
334567AGGGGG
334567BGGGFD

is there any way this can be done with a simple mapping or do I have to use a UDF

Many thanks

Rob

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

It can be achieved by using XSLT mapping. Please find the below transformation:

<xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 

<xsl:output omit-xml-declaration="yes" indent="yes"/> 

<xsl:strip-space elements="*"/>  

<xsl:key name="kFieldByVendor" match="Field"   use="concat(@name, '+', @displayName)"/>  

<xsl:template match= "Field[generate-id()= generate-id(key('kFieldByVendor',concat(@name, '+', @displayName))[2])]">     

<xsl:copy-of select="key('kFieldByVendor',concat(@name, '+', @displayName))"/> 

</xsl:template> </xsl:stylesheet>

Best Regards,

Sagarika Mishra

robert_warde4
Active Participant
0 Kudos

Does anyone have an suggestions on how this can be implemented using XSLT?

Former Member
0 Kudos

Hi,

I am not sure why do u want xslt for this?? It can be achieved using simple graphical mapping and a 3 line UDF

UDF-> Count

Execution type all values of a context

Input: Var1

int a=var1.length;

if (a>1)

{

for(int i=0;i<2;i++)

result.addValue(var1[i]);

}

Note: Do remember to change the context of all the source field to its Message type name.

Thanks

Amit Srivastava

rajasekhar_reddy14
Active Contributor
0 Kudos

I dont think you need JAVA / XSLT mapping,using Standard mapping functionality only can be done.

Let me try and come back to you

baskar_gopalakrishnan2
Active Contributor
0 Kudos

One standard approach is use java mapping or XSLT mapping and remove the single key records.