ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Converting CDATA XML into encoded un-formatted string

Post new topic  Reply to topic Goto page Previous  1, 2
 Converting CDATA XML into encoded un-formatted string « View previous topic :: View next topic » 
Author Message
wmbv7newbie
PostPosted: Wed May 14, 2014 4:43 am    Post subject: Reply with quote

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, ']]>', ']]]]><![CDATA[>');

This doesnt work though.

Thanks!
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed May 14, 2014 5:03 am    Post subject: Reply with quote

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
View user's profile Send private message
kimbert
PostPosted: Wed May 14, 2014 7:18 am    Post subject: Reply with quote

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
View user's profile Send private message
wmbv7newbie
PostPosted: Wed May 14, 2014 10:08 pm    Post subject: Reply with quote

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 &lt; 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
View user's profile Send private message
kimbert
PostPosted: Thu May 15, 2014 4:46 am    Post subject: Reply with quote

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
View user's profile Send private message
wmbv7newbie
PostPosted: Thu May 15, 2014 5:08 am    Post subject: Reply with quote

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, ']]>', ']]]]><![CDATA[>');
             DELETE FIELD OutputRoot.XMLNSC.hris:Dispatch.hris:XML;


Incase, someone has a similar issue.

Thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page Previous  1, 2 Page 2 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Converting CDATA XML into encoded un-formatted string
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.