| |
|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
| Converting CDATA XML into encoded un-formatted string |
« View previous topic :: View next topic » |
| Author |
Message
|
| wmbv7newbie |
Posted: Wed May 14, 2014 4:43 am Post subject: |
|
|
Centurion
Joined: 13 May 2014 Posts: 121
|
I have tried the below esql -
REPLACE (OutputRoot.XMLNSC.hris:Dispatch.hris:XML.Envelope.Packet.(XMLNSC.CDataField)Payload, ']]>', ']]]]>< |
| Vitor |
Posted: Wed May 14, 2014 5:03 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
| wmbv7newbie wrote: |
| Any hints on how to escape the CDATA end tags for inside CDATA section? Otherwise it is giving me invalid xml (as expected). |
Because having CDATA within CDATA is an invalid construct. So that won't work.
Does the third party understand XML? A number of clients/vendors in my experience believe strongly that it's a text document with .a xml not .txt and a lot of mathmatical symbols in it, and have become discouraged/violent when I've been forced to explain that it isn't and the constructs they want to use just won't work.
If I had $5 for each "XML" document I've seen with:
| Code: |
| <Name>Smith & Weston</Name> |
in it I'd have retired. Was once told by a client's FTE that a piece of Java was "highly efficient" because it "didn't bother with all that DOM & SAX nonsense" and "just built a string because that's all XML is".
In fairness and to our regular readers who are aware of my views and biases, I must add that the Java consultant on my team sitting next to me sprayed his desk with coffee at this comment. But the guy was serious. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
| Back to top |
|
 |
| kimbert |
Posted: Wed May 14, 2014 7:18 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5543 Location: Southampton
|
| Quote: |
| we were able to convince them that CDATA would work. We tried with a part of the message and it worked, luckily. |
There is no 'luck' involved here. Any XML processor that is capable of handling a SOAP request is 99.999% likely to support the entire XML specification.
| Quote: |
| But the complete message again gave errors because it would be a CDATA section within another CDATA section |
I think this is the first time that you have explained the entire message structure that you are trying to generate. I did ask specifically for this information.
| Quote: |
| Any hints on how to escape the CDATA end tags for inside CDATA section? |
This is standard XML processing stuff. StackOverflow will have the answer. But I suggest that you re-examine whether you really want to next CDATA sections in this way. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
| Back to top |
|
 |
| wmbv7newbie |
Posted: Wed May 14, 2014 10:08 pm Post subject: |
|
|
Centurion
Joined: 13 May 2014 Posts: 121
|
Hi kimbert,
Thanks for the reply.
| Quote: |
| There is no 'luck' involved here. Any XML processor that is capable of handling a SOAP request is 99.999% likely to support the entire XML specification. |
Luck was the remaining 0.001%.
| Quote: |
| I think this is the first time that you have explained the entire message structure that you are trying to generate. I did ask specifically for this information. |
I gave the whole message in previous post. There it had tags < and gt;, as expected by client and not CDATA. Hence, the issue of CDATA within CDATA was not thought of.
| Quote: |
| This is standard XML processing stuff. StackOverflow will have the answer. But I suggest that you re-examine whether you really want to next CDATA sections in this way. |
I agree. So, I used the REPLACE function to escape the end tags for inner CDATA from StackOverflow. Since the REPLACE is not working, I wanted to know if such manipulation within CDATA sections are not permitted in esql? |
|
| Back to top |
|
 |
| kimbert |
Posted: Thu May 15, 2014 4:46 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5543 Location: Southampton
|
| Quote: |
| I used the REPLACE function to escape the end tags for inner CDATA from StackOverflow. Since the REPLACE is not working, I wanted to know if such manipulation within CDATA sections are not permitted in esql? |
Your string manipulation only works if you are treating the XML document as a string. Message broker and IIB do not. They treat it as a tree ( and so do most other XML processing applications ).
The goal of this technique is to create two CDATA sections. So in ESQL you need to
- Find the start of the nested CDATA section
- Close the first CDATA section immediately before the start of the nested one.
- Create a sibling CDATA section in the message tree and assign the remainder of the text to it. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
| Back to top |
|
 |
| wmbv7newbie |
Posted: Thu May 15, 2014 5:08 am Post subject: |
|
|
Centurion
Joined: 13 May 2014 Posts: 121
|
Thanks for your guidance kimbert.
I tried the below today morning and it worked
| Code: |
-- Converting Payload to CDATA
DECLARE payloadBlob BLOB ASBITSTREAM(rOutEnv.Packet.tempPayload,InputRoot.Properties.Encoding,1208 );
DECLARE payloadChar CHAR CAST(payloadBlob AS CHAR CCSID 1208);
SET rOutEnv.Packet.(XMLNSC.CDataField)Payload = payloadChar;
DELETE FIELD rOutEnv.Packet.tempPayload;
-- Converting outer XML to CDATA
DECLARE wholeMsgBlob BLOB ASBITSTREAM(OutputRoot.XMLNSC.hris:Dispatch.hris:XML,InputRoot.Properties.Encoding,1208 );
DECLARE wholeMsgChar CHAR CAST(wholeMsgBlob AS CHAR CCSID 1208);
SET OutputRoot.XMLNSC.hris:Dispatch.(XMLNSC.CDataField)hris:HRXML = wholeMsgChar;
SET OutputRoot.XMLNSC.hris:Dispatch.(XMLNSC.CDataField)hris:HRXML = REPLACE (OutputRoot.XMLNSC.hris:Dispatch.(XMLNSC.CDataField)hris:HRXML, ']]>', ']]]]>< |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|