on 12-06-2005 11:52 AM
Hi,
I have a problem with the transformation of the tag Content in the e-mail message. I'm very ignorant about xsl and java transformation, but my problem is quite simple.
My message, coming from an R/3 system, is this:
<ns:Mail xmlns:ns="http://sap.com/xi/XI/Mail/30">
<Subject>Hello</Subject>
<From>sender@sender.com</From>
<To>receiver@receiver.com</To>
<Content>row1 \n row2 \n row3</Content>
</ns:Mail>
The only thing I have to do is to test the string in tag Content, and replace \n with EOL.
So my message will become:
<ns:Mail xmlns:ns="http://sap.com/xi/XI/Mail/30">
<Subject>Hello</Subject>
<From>sender@sender.com</From>
<To>receiver@receiver.com</To>
<Content>row1
row2
row3</Content>
</ns:Mail>
Can anyone help me with an XSL transformation or an advanced java function to solve my problem?
I'll be very grateful....
Ilaria
Since the message is coming from R/3, do a simple message mapping with java function converting the "Content" tag contents to the required.
eg, a string function .replaceAll with regex argument specifying '
n' to be replaced with '\n' will solve your problem.
regards,
Felix
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ilaria,
you have the text content as "row1 \n row2 \n row3" which is not actually
"row1
row2
row3"
Hence, in java the string "row1 \n row2 \n row3" is actually represented as "row1
n row2
n row3" because '\n' in java is escape code. So, what you need to do is just to replace your text '\n' to escape code '\n'. If '\n' is a text then the real text present there is '
n' which are 2 chars which had to get converted to one char '\n'.
Since the function is in java you can use a simple java function to and process the input string as
function testfn(String inputstr,Container container)
{
return inputstr.replaceAll("[
n]","\n");
}
This would solve your problem
Best regards,
Felix
Dear Felix,
you've been very very helpful to me.
I had to manage the fact that java function didn't replace substring "\n" nor "
n" nor "[
n]". So I've changed in the input message (abap report from the R/3 system) "\n" with value "&EOL".
Java code now is
return inputstr.replaceAll("&EOL","\n");
and work perfectly!
Thanks a lot!
Ilaria
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.