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 » CDATA within XML Tag

Post new topic  Reply to topic
 CDATA within XML Tag « View previous topic :: View next topic » 
Author Message
gowdy
PostPosted: Thu Sep 20, 2001 4:20 am    Post subject: Reply with quote

Apprentice

Joined: 17 Jul 2001
Posts: 29
Location: Bournemouth, UK

Hi

If I have an XML message wrapped in a CDATA tag in another XML tag, is there any easy way within MQSI to extract the XML message keeping the XML hierarchy.
For example,
<MAIN>
<![CDATA[<MSG>
<SECOND>
<THIRD></THIRD>
</SECOND>
<FOURTH></FOURTH>
</MSG>]]>
</MAIN>
and I want to extract the <MSG> message and all its children as an XML message.

Any assistance gratefully appreciated.

Mark
Back to top
View user's profile Send private message Send e-mail
kolban
PostPosted: Thu Sep 20, 2001 5:44 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2001
Posts: 1072
Location: Fort Worth, TX, USA

Mark,
I did something like this recently. The trick is to extract the data from the CDATA section and then pass through a Reset Content Descriptor node using XML as the message domain.
Back to top
View user's profile Send private message
crossland
PostPosted: Thu Mar 12, 2009 1:47 pm    Post subject: Reply with quote

Master

Joined: 26 Jun 2001
Posts: 248

Well, I have been trying to extract CDATA which contains XML and put it into its own message. After a fair bit of searching through manuals and forums, I have come up with this:

SET OutputRoot.BLOB.BLOB = CAST(InputRoot.XMLNSC.(XMLNSC.CDataValue)Field1 AS BLOB CCSID InputProperties.CodedCharSetId);

This is then fed into a RCD with Message Domain = XMLNSC and Reset Message Domain selected.

The output message is blank.

What have I missed?

Thanks for any advice.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Mar 12, 2009 2:28 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Which output message? The BLOB message or the XMLNSC message after the RCD?
Back to top
View user's profile Send private message
kimbert
PostPosted: Thu Mar 12, 2009 2:43 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
The output message is blank.

What have I missed?
Well, you have missed ( from your last post ) a description of the steps that you took to diagnose this problem. Have you disconnected the debugger, added Trace nodes and taken a user trace? If not, you should do that now.

btw, some users prefer to use CREATE...PARSE rather than an RCD node for this task. If you search this forum, you should find them
Back to top
View user's profile Send private message
Gaya3
PostPosted: Thu Mar 12, 2009 10:00 pm    Post subject: Reply with quote

Jedi

Joined: 12 Sep 2006
Posts: 2493
Location: Boston, US

kimbert wrote:

btw, some users prefer to use CREATE...PARSE rather than an RCD node for this task. If you search this forum, you should find them


I agree with this kimbert, the performance is good if we are using
CREATE...PARSE statement.


_________________
Regards
Gayathri
-----------------------------------------------
Do Something Before you Die
Back to top
View user's profile Send private message
vandi
PostPosted: Fri Mar 13, 2009 5:24 am    Post subject: Reply with quote

Acolyte

Joined: 13 Dec 2008
Posts: 67

crossland wrote:
Well, I have been trying to extract CDATA which contains XML and put it into its own message. After a fair bit of searching through manuals and forums, I have come up with this:

SET OutputRoot.BLOB.BLOB = CAST(InputRoot.XMLNSC.(XMLNSC.CDataValue)Field1 AS BLOB CCSID InputProperties.CodedCharSetId);

This is then fed into a RCD with Message Domain = XMLNSC and Reset Message Domain selected.

The output message is blank.

What have I missed?

Thanks for any advice.


Hi,

I think this may help you. Extract the CDATA, and using Create Parse you can reset the format of the data.


SET Environment.Variable.Blob= InputRoot.XML.Staff.Data.(XML.CDataSection);

CREATE LASTCHILD OF Environment DOMAIN ('XML')
PARSE (Environment.Variable.Blob, InputRoot.MQMD.Encoding,InputRoot.MQMD.CodedCharSetId) ;

Thanks
Vandi
Back to top
View user's profile Send private message
kimbert
PostPosted: Fri Mar 13, 2009 5:56 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
I think this may help you
Vandi: No, that is very unhelpful.
- Please do not advise readers of this forum to use the deprecated XML domain.
- Your field Environment.Variable.Blob is not a BLOB. It is of type CHARACTER ( and so the next line will fail )
- crossland's messages may not contain an MQMD. InputRoot.Properties.CodedCharSetId is a better choice.
Back to top
View user's profile Send private message
HOMETOWN47
PostPosted: Mon Mar 16, 2009 2:23 am    Post subject: CDATA into XML Message Reply with quote

Apprentice

Joined: 25 Mar 2003
Posts: 34

I've had a similar scenario where I've wanted to extract the contents of an XML tag that was wrapped in CDATA. I did the following

DECLARE bodyBlob BLOB CAST (InputRoot.XMLNSC.ns:ClmDecisionEngineResponse.response AS BLOB CCSID 1200);

CREATE LASTCHILD OF OutputRoot
DOMAIN ('XMLNSC')
PARSE (bodyBlob
CCSID 1200
ENCODING 0
SET ''
FORMAT ''
TYPE '');

This works for me !!
Back to top
View user's profile Send private message
mikepham
PostPosted: Sun Jun 12, 2011 7:36 pm    Post subject: Re: CDATA into XML Message Reply with quote

Novice

Joined: 17 Mar 2010
Posts: 20

HOMETOWN47 wrote:
I've had a similar scenario where I've wanted to extract the contents of an XML tag that was wrapped in CDATA. I did the following

DECLARE bodyBlob BLOB CAST (InputRoot.XMLNSC.ns:ClmDecisionEngineResponse.response AS BLOB CCSID 1200);

CREATE LASTCHILD OF OutputRoot
DOMAIN ('XMLNSC')
PARSE (bodyBlob
CCSID 1200
ENCODING 0
SET ''
FORMAT ''
TYPE '');

This works for me !!


This idea worked for me as well where the contents of an XML tag that was wrapped in CDATA:

1st input:
Code:
<test><![CDATA[<test_1>testvalue</test_1>]]></test>


Strange thing is it worked for the following input as well

2nd input:
Code:
<test>&lt;test_1&gt;testvalue&lt;/test_1&gt;</test>


In both cases, I got expected output below:

Code:
<test_1>testvalue</test_1>


Could anyone help me explain why it still worked with the 2nd input ?
I thought it should work only for 1st input

Thanks
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sun Jun 12, 2011 9:43 pm    Post subject: Re: CDATA into XML Message Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

mikepham wrote:

This idea worked for me as well where the contents of an XML tag that was wrapped in CDATA:

1st input:
Code:
<test><![CDATA[<test_1>testvalue</test_1>]]></test>


Strange thing is it worked for the following input as well

2nd input:
Code:
<test>&lt;test_1&gt;testvalue&lt;/test_1&gt;</test>


In both cases, I got expected output below:

Code:
<test_1>testvalue</test_1>


Could anyone help me explain why it still worked with the 2nd input ?
I thought it should work only for 1st input

Thanks


And why wouldn't it work? The raw data for field test, whether as CDATA or escaped XML data is the same. So why would you expect to get a different result?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
mikepham
PostPosted: Sun Jun 12, 2011 11:45 pm    Post subject: Re: CDATA into XML Message Reply with quote

Novice

Joined: 17 Mar 2010
Posts: 20

fjb_saper wrote:
And why wouldn't it work? The raw data for field test, whether as CDATA or escaped XML data is the same.


Thanks for your quick response, fjb_saper. Your clarification does help

fjb_saper wrote:
So why would you expect to get a different result?


I'm sorry if my question seems funny, I'm just a newbie on this...

Actually, I'm in the situation with 2nd input. It was sent from other application and replacing &lt; &gt; ... to recover the inner XML message in esql did not work for me

Since it worked for 2nd input, I don't have to ask for changing the sending application to:
+ put a CDATA section around the embedded XML document
+ embed the document without doing any escaping of XML markup characters.

in order to generate message like 1st input
Back to top
View user's profile Send private message
kimbert
PostPosted: Mon Jun 13, 2011 12:04 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:

Since it worked for 2nd input, I don't have to ask for changing the sending application to:
+ put a CDATA section around the embedded XML document
+ embed the document without doing any escaping of XML markup characters.

in order to generate message like 1st input
Forgive me for asking, but are you saying this?:
- there is at least one input message which works even when CDATA is not used
- therefore there is no point in asking the sender to use CDATA

CData does not protect against *all* types of badly-formed input document, but it does protect against some of the more common XML problems. You are probably better off using CDATA than not using it. If you want more information, search for CDATA on this site - there is a lot of information out there.
Back to top
View user's profile Send private message
mikepham
PostPosted: Mon Jun 13, 2011 7:55 pm    Post subject: Reply with quote

Novice

Joined: 17 Mar 2010
Posts: 20

kimbert wrote:
Forgive me for asking, but are you saying this?:
- there is at least one input message which works even when CDATA is not used
- therefore there is no point in asking the sender to use CDATA


Hi kimbert... yes that's my thought...

kimbert wrote:
CData does not protect against *all* types of badly-formed input document, but it does protect against some of the more common XML problems. You are probably better off using CDATA than not using it. If you want more information, search for CDATA on this site - there is a lot of information out there.


Thanks for your suggestion, clarification. I will read more post about CDATA in this forum.
I will also consider about asking sender to use CDATA if possible ...for safety
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » CDATA within XML Tag
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.