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 » Converting char to XML

Post new topic  Reply to topic
 Converting char to XML « View previous topic :: View next topic » 
Author Message
_Angus_
PostPosted: Fri Feb 13, 2009 3:03 am    Post subject: Converting char to XML Reply with quote

Acolyte

Joined: 25 Apr 2005
Posts: 54
Location: Edinburgh

I'm trying to think of an ESQL way of converting an XML string to XML. For example:

SET Environment.myXML = '<Top><Angus>Hello</Angus></Top>';

... which will obviously just assign the string value to the myXML element. It would be nice to have:

SET Environment.myXML = CAST('<Top><Angus>Hello</Angus></Top>' AS XML);

but unfortunately that doesn't exist. I've tried to work how to do it using CREATE with PARSE but not succeeded yet!

Any help, pointers or suggestions would be much appreciated

Angus
_________________
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Angus Cooke ~ AngusSoft

Integration Development Tools
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
kimbert
PostPosted: Fri Feb 13, 2009 3:15 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

CASTing and parsing are completely different things. CAST converts from one scalar type to another scalar type. Parsing converts a bitstream to a message tree.

If you use the search button you will find dozens of examples on this forum of how to use CREATE...PARSE. I expect you forgot to specify a CCSID and ENCODING, but you haven't told us what problems you encountered - so I have to guess.
Back to top
View user's profile Send private message
dk27
PostPosted: Fri Feb 13, 2009 3:19 am    Post subject: Reply with quote

Acolyte

Joined: 28 Apr 2008
Posts: 51

Can you plz try this?

DECLARE inCCSID INT InputProperties.CodedCharSetId;
DECLARE inEncoding INT InputProperties.Encoding;
DECLARE inBitstream BLOB ASBITSTREAM('<Top><Angus>Hello</Angus></Top>', inEncoding, inCCSID);
CREATE LASTCHILD OF OutputRoot DOMAIN('XML')
PARSE(inBitStream, inEncoding, inCCSID, 'DP3UK14002001',
'TestCase', 'XML1', options);


Reg,
D
Back to top
View user's profile Send private message
kimbert
PostPosted: Fri Feb 13, 2009 3:29 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

dk27: why are you recommending the use of the deprecated XML domain?
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Feb 13, 2009 3:33 am    Post subject: Reply with quote

Grand High Poobah

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

dk27 wrote:
Can you plz try this?


If you're going to paraphrase bits of the manual (an activity with some value) please include the original link to give context:

http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r1m0/topic/com.ibm.etools.mft.doc/ak04950_.htm

Thank you.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
_Angus_
PostPosted: Fri Feb 13, 2009 3:34 am    Post subject: Reply with quote

Acolyte

Joined: 25 Apr 2005
Posts: 54
Location: Edinburgh

Yes I know casting and parsing are different - that wasn't a serious suggestion!

An example of CREATE ... PARSE using Unicode of my example above would be nice. I haven't tried anything yet, I just couldn't work out an easy syntax for what I wanted to do from the CREATE syntax doc. The XML string will be in a CHARACTER variable.
_________________
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Angus Cooke ~ AngusSoft

Integration Development Tools
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
kimbert
PostPosted: Fri Feb 13, 2009 5:04 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
An example of CREATE ... PARSE using Unicode of my example above would be nice
The online docs contain examples. Please at least make an attempt to solve this yourself. If you still cannot make it work, please tell us what you tried, and what happened.
Back to top
View user's profile Send private message
_Angus_
PostPosted: Fri Feb 13, 2009 7:17 am    Post subject: Reply with quote

Acolyte

Joined: 25 Apr 2005
Posts: 54
Location: Edinburgh

Indeed - as my plan to get some quick help on here failed I've already been working it out myself.

DECLARE AuditAdminXml CHARACTER '<Top><Angus>Hello</Angus></Top>';

DECLARE xmlBlob BLOB CAST(AuditAdminXml AS BLOB CCSID 1200);
CREATE LASTCHILD OF Environment.AuditAdmin DOMAIN ('XMLNS') PARSE (xmlBlob, 0, 1200);


... does exactly what I need if anyone else finds this useful.

Cheers

Angus
_________________
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Angus Cooke ~ AngusSoft

Integration Development Tools
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
mqjeff
PostPosted: Fri Feb 13, 2009 7:22 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Well, it's close.

You forgot a C.


Please don't use the XMLNS domain...
Back to top
View user's profile Send private message
_Angus_
PostPosted: Fri Feb 13, 2009 7:55 am    Post subject: Reply with quote

Acolyte

Joined: 25 Apr 2005
Posts: 54
Location: Edinburgh

Yup, I have changed it to the compact parser (and utf-8 ) but purely for performance reasons. The XML I'm manipulating is just naked XML so I don't care about any extras. I know the XML parser is bad but how bad is the XMLNS one?!
_________________
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Angus Cooke ~ AngusSoft

Integration Development Tools
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
mqjeff
PostPosted: Fri Feb 13, 2009 7:58 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

_Angus_ wrote:
I know the XML parser is bad but how bad is the XMLNS one?!

It's not "bad", per se.

But it's on the order of 400% slower... why drive a ten year old car when you can drive a Veyron?
Back to top
View user's profile Send private message
kimbert
PostPosted: Fri Feb 13, 2009 8:45 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Glad you got it working.
I expect you're aware that some CREATE LASTCHILD statements would have done the same job at least as quickly, but I presume you are doing it this way for readability /maintainability.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Feb 13, 2009 9:03 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

I expect that the actual XML he needed to parse wasn't quite so simple...
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 » Converting char 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.