on 12-21-2006 6:08 PM
My Scenario is File to File. XI ( we are PI7.0) receives XML File and I'm splitting ( transorming ) into multiple files in Mapping. Scenario is failing because data contains '&' ( for example K&K Company ). Even XMLFox or XMLSpy gives error saying & is illegal character. Do I have to use encoding 8859-1 instead of utf-8 ? Does that solves my problem ?. Or Do I have to setup or change JDK ?
Can someone help me what I have to do to fix this error?
Sorry..I was not able to reward points. I can not see tabs to award points as we used in SDN forums earlier. How Can I award points ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The character & is not allowed in XML. The program which creates your XML file has to provide & instead. If you cannot change the sender, than you have to write a Java mapping program which escapes the &
Regards
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Jai, Thank you for suggession. As I donot have NetWeaver Developer Studio, How can I do that. Is there any standard routine available to use ? ( I mean .jar file ). Would you please guide me.
Instead of Java Mapping can I do that using Graphical Message mapping ?
My Input XML will look like
<Start_rec>
<Company>
<Name>abc&abc</Name>
<Name>xyz</Name>
..........
</Company>
</Start_rec>
Since its only single record ( 0.. unbounded) Is it possible If I can do that using Graphical Message Mapping ?.. Thanks a lot for any insights ..
In case its only a single record then you can use the string funtctions in XI.
First use Boolean function to check whether it is <b>&</b>, If yes,then replace with the string <b>&</b>
In case it is not a single record, then you have to use Java mapping, and you dont need NWDS for it. you can alwys use a textpad or an eclipse to do it. you will get lots of help on net for this.
Stephan,
Sending system is a legacy system and they are genearting XML file. & character is very common in names of companies or stores etc etc. I believe its not fair to ask them ( Its Legacy system )to change . They wont agree for example 'Procter&Gample' to 'Procter& amp ; Gamble' . Let me try what Vijaya is suggested.
Message was edited by:
S T
Stephan,
actually this input message consists of multiple files wrapped with XML tags genearated around each record. XI splits these file into multiple single files.
To Be exact it will be like this
<Files>
<File1>
<File1Rec>K&K Company</File1Rec1>
<File1Rec>abcd&abcd</File1Rec>
</File1>
<File2>
<File2Rec>itsnot fair</File2Rec>
</File2>
<File3>
<File3Rec>its fair</File3Rec>
</File3>
<File4>
</File4>
All 4 files above are 0...unbounded
We are doing this since we donot want to deliver one before the other as they will processed together in dest system as they are related to each other. This is the reason I'm not doing content conversion on the Inbound side as this message comes with XML tags wrapped around.
XI uses BPM to split into 4 files.
Content conversion on the outbound side and finally each file will be in csv format.
In Short they donot want to do convert & to "& amp ;" simply because they dont know what xml is.
So I need to figure out within XI itself to tackle this issue. Thx
</Files>
When you are sure, that no escape sequence is inside the XML, then you can easily replace all & to &amp;.
Here is a sample code:
public void execute (InputStream in, OutputStream out)
throws StreamTransformationException {
try {
int c;
while ((c = in.read()) != -1) {
if (c != '&') {
out.write(c);
} else {
// ampersand
out.write("&amp;".getBytes());
}
} // while
out.flush();
} catch (Exception e) {
throw new StreamTransformationException(e.getMessage(),e);
}
}
Check also this blog:
/people/stefan.grube/blog/2006/10/23/testing-and-debugging-java-mapping-in-developer-studio
Hope that helps,
Stefan
Just download the 2.2.zip file. After that, unzip it and include commons-lang.jar in your mapping's classpath.
Then do something like this in your Java mapping:
public void execute (InputStream in, OutputStream out)
throws StreamTransformationException {
try {
out.write(StringEscapeUtils.escapeXml(in.read_string()).getBytes());
}
}
After this, your message is properly escaped, you can use graphical mapping or another Java mapping to finish the work. To test in XI, make sure you upload commons-lang.jar file into imported archive. This library will be available to your mapping class.
Hope this will help.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.