Skip to Content
0
Former Member
Feb 08, 2011 at 10:07 AM

converting CSV file coming as string in one of the field of xml to XML

120 Views

Hi ,

we have the below requirement where the dat type is :

DT_MESSAGE

field1 Data

field2 DataString

the csv file of the below format will be sent in the DataString field of xml .

Source;EIX3;Date;080526;Charge;70199;Si;.42 ;Fe;.20 ;Cu;.00 ;Mn;.027 ;Mg;.49 ;Cr;.0007 ;Ni;0 ;Zn;.01 ;Ti;.01 ;Ag;0 ;B;0 ;Ba;0 ;Be;0 ;Bi;0 ;Ca;0 ;Cd;0 ;Co;0 ;Ga;0 ;Na;0 ;Nb;0 ;Pb;0 ;Sb;0 ;Sn;0 ;Sr;0 ;V;0 ;Zr;0 ;Al;0 ;P;0 ;Hg;0 ;Li;0 ;Alloy;606044;Alloy_Hy;AC10;Diametre;152;Client;IMPOL

Source;EXF3;Date;080811;Charge;71460;Si;.04 ;Fe;.10 ;Cu;.002 ;Mn;.003 ;Mg;.002 ;Cr;.0006 ;Ni;.003 ;Zn;.014 ;Ti;.000 ;Ag;0 ;B;0 ;Ba;0 ;Be;0 ;Bi;0 ;Ca;0 ;Cd;0 ;Co;0 ;Ga;0 ;Na;0 ;Nb;0 ;Pb;.0010 ;Sb;0 ;Sn;.000 ;Sr;0 ;V;.001 ;Zr;0 ;Al;99.8 ;P;0 ;Hg;0 ;Li;0 ;Alloy;400101;Alloy_Hy;831B9901;Diametre;PFA;Client;DANFOSS

Source;EXF3;Date;080813;Charge;71535;Si;9.55 ;Fe;.12 ;Cu;1.05 ;Mn;.01 ;Mg;.38 ;Cr;.0008 ;Ni;.00 ;Zn;.01 ;Ti;.01 ;Ag;0 ;B;0 ;Ba;0 ;Be;0 ;Bi;0 ;Ca;.0011 ;Cd;0 ;Co;0 ;Ga;0 ;Na;.0006 ;Nb;0 ;Pb;.0010 ;Sb;.0003 ;Sn;.00 ;Sr;.0002 ;V;0 ;Zr;0 ;Al;0 ;P;.0008 ;Hg;0 ;Li;.0001 ;Alloy;444205;Alloy_Hy;Al AS9C1;Diametre;PFA;Client;TEKSIDPL

Source;EXF3;Date;080813;Charge;71538;Si;9.57 ;Fe;.12 ;Cu;1.01 ;Mn;.01 ;Mg;.39 ;Cr;.0008 ;Ni;.00 ;Zn;.01 ;Ti;.01 ;Ag;0 ;B;0 ;Ba;0 ;Be;0 ;Bi;0 ;Ca;.0007 ;Cd;0 ;Co;0 ;Ga;0 ;Na;.0004 ;Nb;0 ;Pb;.0010 ;Sb;.0004 ;Sn;.00 ;Sr;.0002 ;V;0 ;Zr;0 ;Al;0 ;P;.0007 ;Hg;0 ;Li;.0001 ;Alloy;444205;Alloy_Hy;Al AS9C1;Diametre;PFA;Client;TEKSIDPL

Source;EIX3;Date;080813;Charge;71539;Si;.06 ;Fe;.19 ;Cu;.00 ;Mn;.00 ;Mg;.00 ;Cr;0 ;Ni;0 ;Zn;.01 ;Ti;.01 ;Ag;0 ;B;0 ;Ba;0 ;Be;0 ;Bi;0 ;Ca;0 ;Cd;0 ;Co;0 ;Ga;0 ;Na;0 ;Nb;0 ;Pb;0 ;Sb;0 ;Sn;0 ;Sr;0 ;V;0 ;Zr;0 ;Al;99.71 ;P;0 ;Hg;0 ;Li;0 ;Alloy;107070;Alloy_Hy;AC99.7;Diametre;152;Client;ARO TUBI

where the starting field is Sorce of each row .

I need to parse the above csv using xslt or java mapping .

The target structure xml is

DT_Target

row 0 to unbounded

field 1 Source

field2 Date

field3 Charge

.........

field n Client

can anyone help me how to parse and map to the target.what could be the better method to do it.

Thanks and Regards,

Rajesh