cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Encoding version replacment in xml file

former_member277492
Participant
7,068

Hello Experts,

I have got a requirement where Incoming xml with encoding version 'UTF-8' as below and output file is expected with 'ISO-8859-1' tag.

Input:<?xml version="1.0" encoding="UTF-8"?>

Output: <?xml version="1.0" encoding="ISO-8859-1"?> (Required)

Sample file structure below;

<?xml version="1.0" encoding="UTF-8"?>

<EMPLEADOS>

<EMPLEADO NUMERO="100000676" TIPO="A">

<PROCESO PAC="000000" PERIODO="12345" TT="MN"/>

<SECCION ID="ABCD">

<CAMPO1 FECHA="" ID="PTP_POCATP" SEC="">0.97</CAMPO1>

<CAMPO2 FECHA="" ID="PTP_SPPOC105" SEC="">39.0</CAMPO2>

</SECCION7>

</EMPLEADO>

</EMPLEADOS>.

Do we have any groovy to fulfil this requirement. Please suggest.

Thanks in advance,

Best Regards,

Sree

View Entire Topic
VijenderGouda
Active Participant
0 Likes

Hi sreekar ,

As explained above please store the value as a property" CamelCharsetName"

After that please use the below code in the mapping then you will achieve the data as output:

import com.sap.it.api.mapping.*;
import com.sap.it.api.mapping.MappingContext;
def String getProperty(String CamelCharsetName, MappingContext context) {
    def propValue= context.getProperty(property_name);
    return propValue;
}

Where You need to pass constant as " CamelCharsetName" to the Script and Map the target field.

Regards,
Vijender