cancel
Showing results for 
Search instead for 
Did you mean: 

XML with an Reciever Fileadapter and encoding-problem

Former Member
0 Kudos

Hi.

I'm sending an XML file to an FTP-server.

In the adapter I have set Filetype to TEXT,

and File Encoding to ISO-8859-1.

The file contain som spesial characters, Æ, Ø Å etc.

Got an error when I try to open it with ex. IE.

When I look at the file on the FTP-server the encoding in the XML-header looks like this.: <?xml version="1.0" encoding="UTF-8" ?> .

I would like it to look like this.: <?xml version="1.0" encoding="ISO-8859-1" ?>

Can someone help me with this problem ?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

stefan_grube
Active Contributor
0 Kudos

Check this blog:

/people/stefan.grube/blog/2007/02/02/remove-namespace-prefix-or-change-xml-encoding-with-the-xmlanonymizerbean

Set file type to binary, when you work with the XMLAnonymizerBean.

Regards

Stefan

Answers (6)

Answers (6)

Former Member
0 Kudos

Thank you Stefan.

Your tip below solved my problem.

Set file type to binary, when you work with the XMLAnonymizerBean

Former Member
0 Kudos

Hi,

Follow this link

https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/9420 [original link is broken] [original link is broken] [original link is broken]

Former Member
0 Kudos

I tried Transfer Mode to TEXT, but it dis'nt help.

I found a SAP-note 880173 which described how to use the Anonymizer Module i the file adapter but i'm not sure how to set the parameters.

Can someone tell me if I'm on the wrong track?

XSLT Mapping can't I use because I cant create the XSL-file.

Former Member
0 Kudos

Hi,

Better try FTP file transfer mode, file type as text and save a file name as text.

Thanks,

Boopathi

Former Member
0 Kudos

Hi,

Here is the solution:

In FTP connection Parameter please Change the Transfer Mode to TEXT.

Thanks,

Boopathi

GabrielSagaya
Active Contributor
0 Kudos

You can use the following XSLT Mapping to change the codepage of an XML document.

from utf-8 to encoding ISO-8859-1.

***************************************

Change it to the required encoding of the target XML.

<xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" encoding="ISO-8859-1"/>

<xsl:template match="/">

<xsl:copy-of select="*" />

</xsl:template>

</xsl:stylesheet>

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/how-to-guides-rig-...

Also You can use the following Java mapping to change the codepage of a text document.

package com.sap.encoding.example;

import java.io.*;

import java.util.*;

import com.sap.aii.mapping.api.*;

public class UTFISO implements StreamTransformation {

private final String latin = "ISO-8859-1";

private final String utf ="UTF-8";

public void execute(InputStream in, OutputStream out) {

try {

DataInputStream stdin = new DataInputStream(in);

int length = getLengthFromStream(stdin);

stdin.reset();

byte[] buffer = getBytesFromStream(stdin);

String str = new String(buffer, utf);

str = str.replaceAll(utf, latin);

out.write(str.getBytes(latin));

out.close();

} catch (IOException e) {

}

}

public int getLengthFromStream(InputStream is ) throws

IOException{

int i = 0;

int length = 0;

try{

while ((i = is.read())> 0){

length ++;

}

}catch (ArrayIndexOutOfBoundsException e) {

e.printStackTrace();

}

return length;

}

public byte[] getBytesFromStream(InputStream is) throws

IOException {

// Create the byte array to hold the data

byte[] bytes = new byte[getLengthFromStream(is)];

is.reset();

// Read in the bytes

int offset = 0;

int tmp = 0;

while (offset < bytes.length

&& (is.read(bytes, offset, offset +

(tmp = is.available()))) > 0) {

offset += tmp;

}

// Ensure all the bytes have been read in

if (offset < bytes.length) {

throw new IOException("Could not

completely read Inputstream");

}

// Close the input stream and return bytes

is.close();

return bytes;

}

public void setParameter(Map param) {

}

}

Former Member
0 Kudos

Hi,

Refer the below thread. It is talking about using the correct code page in IE.

chirag