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 » Embedded XML Document

Post new topic  Reply to topic
 Embedded XML Document « View previous topic :: View next topic » 
Author Message
fitzcaraldo
PostPosted: Wed Sep 24, 2003 4:55 pm    Post subject: Embedded XML Document Reply with quote

Voyager

Joined: 05 May 2003
Posts: 98

Hello

I need to embed an XML document inside another XML document. I read the XML document to embed as an incoming message and then set that entire message to a single field in the outgoing message.

The code shown works fine as long as the incoming XML document contains no special fields such as a comment containing a DOCTYPE. The embedded XML document is escaped as I expect.

So if I have leading DOCTYPE statement, I am assuming that InputRoot.XML will have two children, the first being the DOCTYPE and then the actual document. If the DOCTYPE is present, the write to the outgoing queue fails. It looks as if the XML parser is attempting to parse the comment field even though it is escaped (and of course this is not valid XML).

Error: Invalid Target.
The target element must be a name element and may not have a value. In addition, the element must not be marked as 'special'. The supplied element has name '', type '100663320', and value 'DOCTYPE etc etc

I have tried using AsIsElementContent - same problem.

Anyone tried to do this before?

Code:

declare xmlBodyRef reference to InputRoot.XML;
move xmlBodyRef firstchild;
declare xmlBody character '';

while lastmove(xmlBodyRef) = true do

  set xmlBody = xmlBody || cast (ASBITSTREAM(xmlBodyRef OPTIONS FolderBitStream)
      as CHARACTER CCSID InputRoot.MQMD.CodedCharSetId ENCODING InputRoot.MQMD.Encoding);

  move xmlBodyRef nextsibling;
end while;

set OutputRoot.XML.MyMessage.messageData = xmlBody;
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Sep 25, 2003 6:20 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Put the embedded XML in a CDATA field instead of a plain body field.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
fitzcaraldo
PostPosted: Thu Sep 25, 2003 6:55 pm    Post subject: Reply with quote

Voyager

Joined: 05 May 2003
Posts: 98

FYI - this works

Code:

-- build the incoming message into a blob string
declare xmlBodyRef reference to InputRoot.XML;
declare xmlBody blob cast('' as blob);

move xmlBodyRef firstchild;
while lastmove(xmlBodyRef) = true do
  set xmlBody = xmlBody || BITSTREAM(xmlBodyRef);
  move xmlBodyRef nextsibling;
end while;

-- xmlBody should now hold all elements of the message
-- copy it to the messageData field
set OutputRoot.XML.MyMessage.messageData.(XML.Content) = cast (xmlBody
      as CHARACTER CCSID InputRoot.MQMD.CodedCharSetId ENCODING InputRoot.MQMD.Encoding);
[/code]
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Fri Sep 26, 2003 5:23 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

You really should use ASBITSTREAM instead of BITSTREAM, as I understand things.

And you could save some cycles by specifing the CCSID and ENCODING parameters of the ASBITSTREAM function instead of doing an additional CAST.

Maybe what you're seeing that's making the difference is the (XML.Content) descriptor.
_________________
I am *not* the model of the modern major general.
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 » Embedded XML Document
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.