Author |
Message
|
protocol |
Posted: Mon Feb 16, 2009 12:36 pm Post subject: COnvert ^M to CRLF |
|
|
 Apprentice
Joined: 25 Feb 2005 Posts: 41
|
Hello,
We are getting a BLOB from Mainframe, our Broker runs on AIX and we make a Http Request to Windows.
The Http Request seems to be failing and the reason is because the CDATA section has ^M's, where it should have been CRLF placing the various items in the CDATA section in different lines.
How can I remove the ^M's and send it as CRLF to windows?
Any help is appreciated.
Thanks! |
|
Back to top |
|
 |
Tibor |
Posted: Mon Feb 16, 2009 1:32 pm Post subject: |
|
|
 Grand Master
Joined: 20 May 2001 Posts: 1033 Location: Hungary
|
Just use the REPLACE function in the BLOB domain:
Code: |
SET OutputRoot.BLOB.BLOB = REPLACE(InputRoot.BLOB.BLOB, X'0d', X'0d0a'); |
|
|
Back to top |
|
 |
protocol |
Posted: Mon Feb 16, 2009 1:58 pm Post subject: |
|
|
 Apprentice
Joined: 25 Feb 2005 Posts: 41
|
Tibor,
Thank you very much!! That worked!! |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Feb 16, 2009 3:03 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
It works until you get a message that already has 0x0d0x0a in it, yes.
Perhaps you should entirely rethink your approach of embedding formatted, meaningful data inside XML as an unformatted, meaningless CDATA section. |
|
Back to top |
|
 |
rekarm01 |
Posted: Mon Feb 16, 2009 5:35 pm Post subject: Re: Convert CR to CRLF |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
protocol wrote: |
Hello,
We are getting a BLOB from Mainframe, our Broker runs on AIX and we make a HttpRequest to Windows.
The HttpRequest seems to be failing and the reason is because the CDATA section has ^M's, where it should have been CRLF placing the various items in the CDATA section in different lines. |
XML parsers usually try to normalize end-of-line terminators automatically, (including within CDATA segments).
This is but one benefit that makes them a bit more useful than BLOB parsers, when processing XML messages. |
|
Back to top |
|
 |
Tibor |
Posted: Tue Feb 17, 2009 2:51 am Post subject: |
|
|
 Grand Master
Joined: 20 May 2001 Posts: 1033 Location: Hungary
|
mqjeff wrote: |
It works until you get a message that already has 0x0d0x0a in it, yes. |
I don't understand it, because 0x0d0x0a is not a valid BLOB fragment. |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Feb 17, 2009 3:15 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Tibor wrote: |
mqjeff wrote: |
It works until you get a message that already has 0x0d0x0a in it, yes. |
I don't understand it, because 0x0d0x0a is not a valid BLOB fragment. |
Sorry, change in nomenclature. If you run the replace against a message that already has X'0d0a' instead of just X'0d', you will get X'0d0a0a'. |
|
Back to top |
|
 |
Tibor |
Posted: Tue Feb 17, 2009 3:23 am Post subject: |
|
|
 Grand Master
Joined: 20 May 2001 Posts: 1033 Location: Hungary
|
To avoid this scenario, should transform in 2 steps:
1. replace CRLF to LF
2. replace LF to CRLF
On a first view it seems a little bit strange, but can work without the duplication problem. |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Feb 17, 2009 3:31 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Tibor wrote: |
To avoid this scenario, should transform in 2 steps:
1. replace CRLF to LF
2. replace LF to CRLF
On a first view it seems a little bit strange, but can work without the duplication problem. |
Yes,but again. Protocol should perhaps reconsider how the data being passed is packaged... |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Feb 17, 2009 3:51 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
|
Back to top |
|
 |
|