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 » Parsing BLOB to XML

Post new topic  Reply to topic Goto page 1, 2  Next
 Parsing BLOB to XML « View previous topic :: View next topic » 
Author Message
amol5985
PostPosted: Wed Sep 29, 2010 11:28 pm    Post subject: BLOB to XML Converstion thr ESQL Reply with quote

Newbie

Joined: 29 Sep 2010
Posts: 5

Hi all,

sorry to start this post again.

I have specific requirement, i want to convert from Input BLOB to XML.
I dont have any message set and i cant use RCD.
Message can be in continuous tag format like : <Emp><Name>XYZ</Name></Emp>
or it can be in continuous string format like : XYZ PQR 24
as it is in BLOB.

Can anyone tell me how i can achieve this thr ESQL coding.

Thanks
Back to top
View user's profile Send private message Send e-mail
Vitor
PostPosted: Thu Sep 30, 2010 4:08 am    Post subject: Re: BLOB to XML Converstion thr ESQL Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

amol5985 wrote:
sorry to start this post again.


I was sorry as well. Split from this
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Sep 30, 2010 4:15 am    Post subject: Re: BLOB to XML Converstion thr ESQL Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

amol5985 wrote:
I have specific requirement, i want to convert from Input BLOB to XML.
I dont have any message set and i cant use RCD.
Message can be in continuous tag format like : <Emp><Name>XYZ</Name></Emp>
or it can be in continuous string format like : XYZ PQR 24
as it is in BLOB.


The first and obvious question is how you intend to parse the non-XML without using a message set. Are you seriously saying your requirement is to grind through the string character by character? If so you need to push back.

The second and linked question is why you can't use an RCD.

The third question is what have you tried already & what happened.

On the face of it it's fairly straightforward from what you've posted; simplistically you could parse the BLOB as XML & if the parsing fails run it through a message set.

Other more elegant solutions are almost certainly possible.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
vikas.bhu
PostPosted: Mon Oct 04, 2010 9:32 pm    Post subject: Reply with quote

Disciple

Joined: 17 May 2009
Posts: 159

Please try first by your self..then come to forum..as very senior guys come here to answer questions..
Back to top
View user's profile Send private message Send e-mail
amol5985
PostPosted: Mon Oct 04, 2010 11:03 pm    Post subject: I got my output Reply with quote

Newbie

Joined: 29 Sep 2010
Posts: 5

Hey all,

I got BLOB to XML transformation through following line of code

DECLARE inCCSID INT InputProperties.CodedCharSetId;
DECLARE inEncoding INT InputProperties.Encoding;
DECLARE inBitStream BLOB ASBITSTREAM(InputRoot.BLOB, inEncoding, inCCSID);
CREATE LASTCHILD OF OutputRoot DOMAIN('XMLNSC') PARSE(inBitStream, inEncoding, inCCSID,'BLOB', 'XMLNSC');


Thanks for suggestion
Back to top
View user's profile Send private message Send e-mail
Vitor
PostPosted: Tue Oct 05, 2010 4:07 am    Post subject: Re: I got my output Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

amol5985 wrote:
I got BLOB to XML transformation through following line of code


Well congratulations.

How are you coming with the 2nd situation you mentioned:

amol5985 wrote:
it can be in continuous string format like : XYZ PQR 24


without a message set?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
amol5985
PostPosted: Tue Oct 05, 2010 9:17 pm    Post subject: Reply with quote

Newbie

Joined: 29 Sep 2010
Posts: 5

i come to know later, that my input will be in following format
<Emp><Name></Name><Age></Age></Emp>

Input will come in continuous string but it will contain tags.
Back to top
View user's profile Send private message Send e-mail
smdavies99
PostPosted: Tue Oct 05, 2010 11:03 pm    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

amol5985 wrote:
i come to know later, that my input will be in following format
<Emp><Name></Name><Age></Age></Emp>

Input will come in continuous string but it will contain tags.


In Pure XML Terms
Code:

<Emp><Name>Fred Flintstone</Name><Age>40</Age></Emp>


is no different from
Code:

<Emp>
    <Name>Fred Flintstone</Name>
    <Age>40</Age>
</Emp>

Pretty well any XML Parser I have ever used (well except the first one I ever wrote..) will treat the formats identically. The important thing is that the data is in the tags. Everything else is whitespace and is ignored.

Both format have their uses.
The all on one line format is useful for putting multiple complere messages into one file and using something like a FileInputNode to treat every line as a message.
The One Message per file format is useful where the message is complex as it is more human readable.

Remember that you can only have one ROOT TAG per complete set of XML Data.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
amol5985
PostPosted: Wed Oct 06, 2010 12:53 am    Post subject: Reply with quote

Newbie

Joined: 29 Sep 2010
Posts: 5

I think ur right, but here we are treating first format as BLOB.
I am passing msg thr RFHUTIL in RFH tab, i keep each filed blank like domain, set, format, type are blank. so by default it treat that message as BLOB.
Back to top
View user's profile Send private message Send e-mail
kimbert
PostPosted: Wed Oct 06, 2010 1:18 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
I think ur right, but here we are treating first format as BLOB.

smdavies99 is correct - both formats are XML and there is no debate about that.
a) Why are you treating the single-line XML as a BLOB? Did somebody tell you to do that, or did you make a mistake and think that it was not valid XML?
b) Now that you know that both formats are XML, are you going to use the XMLNSC domain for both formats?
Back to top
View user's profile Send private message
alerajeshh
PostPosted: Wed Sep 25, 2013 11:29 am    Post subject: Reply with quote

Acolyte

Joined: 19 Aug 2013
Posts: 55

Hi i think my situation is similar..
Iam Retrieving a row from database which is in xml format with continuous tags

while am retrieving it thorugh esql :

Set outputRoot.BLOB[]=Select p.xml from table_name as p;

the output isBLOB---- > XML

where the XML is in BLOB format..

now i want to convert the blob into XML (continuous tags)..

i dont knw what am doing...do i need to create message set for that..because creating message for that is hectic (XML is complicated)..

please guide me


Last edited by alerajeshh on Wed Sep 25, 2013 11:39 am; edited 2 times in total
Back to top
View user's profile Send private message
smdavies99
PostPosted: Wed Sep 25, 2013 11:35 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

Please don't reopen a three year old post.

It is far better to start a new one and then reference the old one.

That said, I'm very confused by this bit of your post

Quote:

where the XML is in BLOB format..


Can you please explain how data in one physical format can also be in another?
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
alerajeshh
PostPosted: Wed Sep 25, 2013 11:38 am    Post subject: Reply with quote

Acolyte

Joined: 19 Aug 2013
Posts: 55

Iam Sorry for that....its just like the table column name is XML so unde the BLOB it is coming like XML(variable)..dont worry about that...

can u let me knw how to transform a blob format into xml format (without using message set)
Back to top
View user's profile Send private message
kimbert
PostPosted: Thu Sep 26, 2013 12:14 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

So the database is returning a BLOB, and you want to parse that BLOB into a message tree.

A few pointers for you:
1. Don't use OutputRoot as a holder for temporary data. That used to be necessary, but the LocalEnvironment tree has been available for quite a long time now
2. It's not a good idea to treat OutputRoot.BLOB ( or OutputRoot.<anything>) as an array. At least, not unless you are a very advanced user, and you know exactly why you are doing it.
3. To convert a BLOB into a message tree, you parse it. You need to use the CREATE statement with a PARSE clause. There is an example earlier in this thread.
_________________
Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too.
Back to top
View user's profile Send private message
alerajeshh
PostPosted: Thu Sep 26, 2013 5:04 am    Post subject: Reply with quote

Acolyte

Joined: 19 Aug 2013
Posts: 55

SET OutputRoot.XMLNSC=InputRoot.XMLNSC;
Declare xy char;
SET xy= CAST(ASBITSTREAM (InputRoot.XMLNSC )AS CHARACTER CCSID 1208);
INSERT INTO Database.TableName(XML) VALUES (xy);

I have done this for inserting the XML into Table where data type is CLOB.

and for retrieving

SET OutputRoot.XMLNSC[]=SELECT P.XML FROM Database.TableName AS P;

The output is like XMLNSC--- >XML (which contains XML with continuous tags..


Is der any better way for retrieval ...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Parsing BLOB to 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.