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 » Urgent : Concatenating two XML Messages

Post new topic  Reply to topic
 Urgent : Concatenating two XML Messages « View previous topic :: View next topic » 
Author Message
mq_developer
PostPosted: Tue Feb 19, 2002 8:54 am    Post subject: Reply with quote

Voyager

Joined: 18 Feb 2002
Posts: 82

Hi Board,

My requirement is to concatenate two xml messages. One of the message should be read from DB2 database and other is the input message. I am inserting the XML Message into the database using insert statement (INSERT INTO tablename values Root."BLOB"."BLOB") and later on this will be read back for insertion.The datatype of the column in the DB2 database is CHARACTER. When i issue a query on the db i am able to see the XML message as such. But i dont know how to insert read msg from database to the input xml message.

Rightnow i have a code like this in my ESQL
DECLARE Test CHARACTER;
SET Test = (THE (SELECT ITEM T.BLOBDATA FROM Database.MYACCT AS T WHERE T.NEWTAG = InputBody.MQ.NEWTAG1) );

OutputRoot.XML.MSG.NEWPART = Test;

Now the data are getting are inserted and xml tags (from db) are considered as data rather than as tags . Here is the output am i getting
<MSG><OLDPART>some text</OLDPART> <NEWPART>&lt;MQ&gt;&lt;NEWTAG&gt;1&lt;/NEWTAG&gt;&lt;/MQ&gt;</NEWPART>
</MSG>
Following is the value i am reading from database and storing it in Test (see above ESQL)&lt;MQ&gt;&lt;NEWTAG&gt;1&lt;/NEWTAG&gt;&lt;/MQ&gt;
When i query the datbase the value i see is <MQ><NEWTAG>1</NEWTAG></MQ>

Buy i want to have output like
MSG>
<OLDPART>some text</OLDPART>
<NEWPART>
<MQ>
<NEWTAG>1</NEWTAG>
</MQ>
</NEWPART>
</MSG>

Please do advise how to acheive the above and also provide suggestion on db2 column datatypes to store the XML Message.

Thanks all,
Ram
Back to top
View user's profile Send private message
kirani
PostPosted: Tue Feb 19, 2002 8:25 pm    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

Hi Ram,

The replacement of < and > by '&lt;' and '&gt;' takes place because the character value '<MQ><NEWTAG>1</NEWTAG></MQ>' from the database is being assigned to an XML field. The '<' and '>' characters are reserved by XML because they delimit tags and cannot therefore appear directly in the contents of a field.

Where a user wishes to include a '<' or '>' character in an XML field they must use the "special identifiers" &lt; (lt = less than) and &gt; (gt = greater than). Some other characters are similarly restricted, for example a double quote must be represented by '&quot;', an apostrophe by '&apos;'and an ampersand by '&amp;'.

From an XML point of view, <MQ><NEWTAG>1</NEWTAG></MQ> represents valid XML message with 'MQ' and 'NEWTAG' as elements in it that contents value '1', wheras &lt;MQ&gt;&lt;NEWTAG&gt;1&lt;/NEWTAG&gt;&lt;/MQ&gt
represents the character string '<MQ><NEWTAG>1</NEWTAG></MQ>'

This should explain why you are getting the weird characters. Now you will
need to figure out how to replace these if you want the character string to
look like an XML field.

You can try changing the database fields to CLOB. What ESQL code are you using to store XML message into database? Could you post your insert statement here?

Hope this helps!

Kiran
Back to top
View user's profile Send private message Visit poster's website
mq_developer
PostPosted: Tue Feb 19, 2002 8:43 pm    Post subject: Reply with quote

Voyager

Joined: 18 Feb 2002
Posts: 82

Kiran,

My ESQL in compute Node is

INSERT INTO tablename (colname,..) values (Root."BLOB"."BLOB",...) ,
my input to this message flow is a XML and before message comes to the above compute node i am converting it to BLOB using RCD Node. My requirement is to join the above XML tags (read from DB) to an input message in an another message flow.So it comes to
if InputMsg is <MSG><OLDMSG>some text</OLDMSG></MSG> , my output should be
<MSG><OLDMSG>some text</OLDMSG><NEWMSG>xml tags read from DB2 database</NEWMSG></MSG>.

Please do provide some advice on how to do the same.

Cheers,
Ram

Back to top
View user's profile Send private message
kirani
PostPosted: Tue Feb 19, 2002 9:33 pm    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

Hi,

I don't have access to my MQSI server, so I can not experiment with it right now.

I did storage and retrieval of XML message to/from database. In DB2 database the field was defined as BLOB and the eSQL we used for storage was,

INSERT INO Database.TableName(xmlfield) VALUES (BITSTREAM(Root."BLOB"."BLOB"));

To retrieve it from the database we used following ESQL,

SET OutputRoot."BLOB"."BLOB" = THE (SELECT ITEM tbl.xmlfield FROM Database.TableName as tbl WHERE condition .... );

Try changing your database field to BLOB and use BITSTREAM function while inserting into database.

I will try to find out how retrieve XML message from DB into XML element in the tree.

Regards,
Kiran
Back to top
View user's profile Send private message Visit poster's website
mq_developer
PostPosted: Tue Feb 19, 2002 10:58 pm    Post subject: Reply with quote

Voyager

Joined: 18 Feb 2002
Posts: 82

Thanks Kiran,

I am now able to concatenate both XML Messages in the following way ( I inserted into the Table with column type BLOB as you said) and in the other message flow i had a following ESQL in the compute Node

SET OutputRoot."BLOB"."BLOB" = InputRoot."BLOB"."BLOB" || ( SELECT ... FROM tablename)

After this i used a RCD to reparse it as XML and it worked fine. Since the output message formed with the above ESQL has two top level elements (Since InputRoot."BLOB"."BLOB" will be having proper XML message and also from database i get another valid XML message)
i have to change the above code like
SET DummyHeaderStartTAG = x'...';
SET DummyHeaderEndTAG = x'...';
SET OutputRoot."BLOB"."BLOB" = DummyHeaderStartTAG || InputRoot."BLOB"."BLOB" || ( SELECT ... FROM tablename) || DummyHeaderEndTAG ;

I would appreciate if u can let me know if there is any other way to go about it. Thanks.

Cheers,
Ram
Back to top
View user's profile Send private message
Coz
PostPosted: Thu Feb 21, 2002 1:57 am    Post subject: Reply with quote

Apprentice

Joined: 20 Feb 2002
Posts: 44
Location: Basel CH

I am having a similar problem.

Any ideas of how to handle this if the DB field is a CLOB? Can't use BLOB as it's too small.

When I use:

OutputRoot."BLOB"."BLOB" = THE (SELECT ...

It returns far more than the 65K that is actually stored. If I try and cast it to a BIT or BLOB it says 'trying to use a scalar when list returned (or similar) ...'

This is rather urgent and all help most appreciated.
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 » Urgent : Concatenating two XML Messages
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.