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 » Manipulating XML field having another XML

Post new topic  Reply to topic
 Manipulating XML field having another XML « View previous topic :: View next topic » 
Author Message
mmksri
PostPosted: Wed Aug 09, 2006 10:03 pm    Post subject: Manipulating XML field having another XML Reply with quote

Newbie

Joined: 07 Jun 2006
Posts: 7

Hi All,
I need your kind help in resolving one of the issue I am facing here. I am getting a XML on the Broker with one of the field having another stringified ( all mark-ups repalced by their character entities ) xml. I need to convert it to normal XML mark-ups and apply transformation on those fields. I have a sample message below for your reference ( pls note that its not an actual msg. this is a msg I am using to do this POC before going for the actual implementation ).

Code:
<?xml version="1.0" encoding="UTF-8"?>
<contact:Contact xsi:schemaLocation="http://www.ibm.com Contact.xsd " xmlns:contact="http://www.ibm.com" xmlns:xalan="http://xml.apache.org/xslt" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <contact:Name>ABC</contact:Name>
 <contact:PostalAddress>
  <contact:DeliverTo>ABC</contact:DeliverTo>
  <contact:Street>XYZ</contact:Street>
  <contact:payload>&lt;contact:City&gt;Bangalore&lt;/contact:City&gt;</contact:payload>
  <contact:State>Karnataka</contact:State>
  <contact:PostalCode>560040</contact:PostalCode>
  <contact:Country>India</contact:Country>
 </contact:PostalAddress>
 <contact:Email>abc@xyz.com</contact:Email>
</contact:Contact>

pls note that the payload field having stringified XML tags. I need to convert them to regular XML markup and apply transformation.

I want to have it as below before applying transformation :

Code:
<?xml version="1.0" encoding="UTF-8"?>
<contact:Contact xsi:schemaLocation="http://www.ibm.com Contact.xsd " xmlns:contact="http://www.ibm.com" xmlns:xalan="http://xml.apache.org/xslt" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
.
<contact:payload>
<contact:City>Bangalore</contact:City>
</contact:payload>
.
 <contact:Email>abc@xyz.com</contact:Email>
</contact:Contact>


I think we can apply ESQL REPLACE to convert those character entities to mark-up. But please note that character entities can also be part of the data that should not be considered as mark-up. For eg., payload can also have something like,
Code:
<contact:payload>&lt;contact:City&gt;Bangalore&lt;Delhi&lt;/contact:City&gt;</contact:payload>

In the above case &lt; between Bangalore and Delhi should not be treated as mark-up. I am not understanding how to differentiate between character entity references which would form the mark-up and others would be part of the data.

Requesting you to guide me in achieving this. Thanks in advance.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Aug 10, 2006 1:25 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

I think you want to use Create Field..Parse.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
kimbert
PostPosted: Thu Aug 10, 2006 1:28 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

I would try solving a different problem. Why not encode the XML as base64 instead of mangling the markup?
Back to top
View user's profile Send private message
mmksri
PostPosted: Thu Aug 10, 2006 1:46 am    Post subject: Reply with quote

Newbie

Joined: 07 Jun 2006
Posts: 7

Hi All,
Thanks for the response. Infact I have tried the create parse with no luck. pls find the ESQL I had for doing that.

Code:
DECLARE newMsgBlob BLOB ;
DECLARE msgBlob BLOB ;

SET newMsgBlob = REPLACE ( InputRoot.BLOB.BLOB, CAST ('&lt;' AS BLOB CCSID InputRoot.MQMD.CodedCharSetId), CAST ('<' AS BLOB CCSID InputRoot.MQMD.CodedCharSetId));

SET newMsgBlob = REPLACE ( newMsgBlob, CAST ('&gt;' AS BLOB CCSID InputRoot.MQMD.CodedCharSetId), CAST ('>' AS BLOB CCSID InputRoot.MQMD.CodedCharSetId));
      
   CREATE LASTCHILD OF OutputRoot DOMAIN 'XMLNS' PARSE(newMsgBlob);


In this case its replacing the character entity &lt; between the data also resulting in a invalid xml.

Any suggestions would really help..

kimbert - can you please elaborate bit more on the solution you suggested..

Thanks to both of you for your kind reply.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Aug 10, 2006 1:53 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

I meant using Create Field .. Parse on the payload to turn it into XML.

Although now I'm not sure that it will work.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
kimbert
PostPosted: Thu Aug 10, 2006 1:58 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
kimbert - can you please elaborate bit more on the solution you suggested..
I think the input format is poorly-designed. It's going to be tricky to correctly decode the character entities. The usual solution when embedding XML inside XML is to encode it as hexBinary or base64.
Having said that, you may not be able to change the input format. So you have to write a simple 'XML' parser which remembers which opening 'tags' you have seen, and leaves alone any &lt; or &gt; entities which are not expected. A Java Compute node might be the way to go.
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 » Manipulating XML field having another XML
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.