cancel
Showing results for 
Search instead for 
Did you mean: 

XMl not reading '&' value - please help

Former Member
0 Kudos

Hi,

The text file is having an '&' value (in many places). Hence the mapping is failing.

The character '&' is an illegal value in xml.

Is there a solution ?.

The client says that they cannot modify the file. We have no solution in hand.

Please help

It is very urgent.

John

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi !

What about a search and replace script that runs in "Run Operating System Command Before"? it could receive the found filename as input parameter and could do a search and replace of all ampersands.

You could use a java proxy client to read the files, instead of a file adapter, and replace all "&" there and then hand them to the IE.

Or create your own adapter module

http://help.sap.com/saphelp_nw04/helpdata/en/96/f04142099eb76be10000000a155106/content.htm

If you use the one provided as example (converts CRLF to LF or viceversa) you have 80% of the job done.

Regards,

Matias.

Answers (3)

Answers (3)

stefan_grube
Active Contributor
0 Kudos

You have to write a Java Mapping that has to run before the actual mapping. The Java Mapping replaces the & with & amp;

But it has to chack, if the & is not part of an escape sequence, in that case it should not be changed.

This question is asked so often, that I would appreciate if anyone could write a blog for this.

Regards

Stefan

rodrigoalejandro_pertierr
Active Contributor
0 Kudos

Hi

check these thread and verify if any response help you.

Thanks

Rodrigo

prateek
Active Contributor
0 Kudos

Try using file type as binary in the file adapter.

Also u may use "&amp ;" without space instead of &

Regards,

Prateek

Former Member
0 Kudos

Hi,

We cannot replace anything in the file. Cannot touch the file.

If you check w3schools, it clearly says that '&' should not be in xml.

Can XI parser read '&' in any case.

How is it possible ?

Thanks,

john

prateek
Active Contributor
0 Kudos

XI can handle this symbol in this format "& amp ;" without space. If i remove space u ll only see &.

1. So u may try the following. Concat amp; to & in mapping ad then try

2. Write a small adapter module to achieve this

Regards,

Prateek

Former Member
0 Kudos

Hi,

Yes we know that '&amp' is the entity reference for '&' and that it can be used to replace it.

But........................The replacement can be done through mapping, only after the files are read by the SAX parser in XI. !!!!!!!!!

Thats exactly the problem. The parser will not read '&'.

The message is "fatal errror".

Regards,

John

Former Member
0 Kudos

Hello,

how exactly your scenario looks like?

Do you have to make a modification of the file?

Regards

Patrick

Former Member
0 Kudos

Hi,

Someone has suggested that java mapping can help for the transformation of '&' to '&amp'.

The java mapping code will look something like:

public class FixEncoding implements StreamTransformation

{

public void execute(InputStream in, OutputStream out)

throws StreamTransformationException {

String instr;

instr = parseIStreamToString(in);

instr = instr.replace( '&', '&' );

}

But even the DOM parser while reading the xml can give the same parsing error.

Hence is adapter module the only solution ?

former_member192892
Active Contributor
0 Kudos

I think Matias is bang on... Run operating system command can be used and this would help in avoiding the usage of adapter module....

You can even write a small java code or any script to read the file and do the required modifications...

Thanks

Varun