|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Urgent : Concatenating two XML Messages |
« View previous topic :: View next topic » |
Author |
Message
|
mq_developer |
Posted: Tue Feb 19, 2002 8:54 am Post subject: |
|
|
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><MQ><NEWTAG>1</NEWTAG></MQ></NEWPART>
</MSG>
Following is the value i am reading from database and storing it in Test (see above ESQL)<MQ><NEWTAG>1</NEWTAG></MQ>
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 |
|
 |
kirani |
Posted: Tue Feb 19, 2002 8:25 pm Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
Hi Ram,
The replacement of < and > by '<' and '>' 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 = less than) and > (gt = greater than). Some other characters are similarly restricted, for example a double quote must be represented by '"', an apostrophe by '''and an ampersand by '&'.
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 <MQ><NEWTAG>1</NEWTAG></MQ>
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 |
|
 |
mq_developer |
Posted: Tue Feb 19, 2002 8:43 pm Post subject: |
|
|
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 |
|
 |
kirani |
Posted: Tue Feb 19, 2002 9:33 pm Post subject: |
|
|
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 |
|
 |
mq_developer |
Posted: Tue Feb 19, 2002 10:58 pm Post subject: |
|
|
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 |
|
 |
Coz |
Posted: Thu Feb 21, 2002 1:57 am Post subject: |
|
|
 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 |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|