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 » generating string with escape characters from XML

Post new topic  Reply to topic
 generating string with escape characters from XML « View previous topic :: View next topic » 
Author Message
pyrus
PostPosted: Fri Jul 20, 2007 3:27 am    Post subject: generating string with escape characters from XML Reply with quote

Novice

Joined: 20 Jul 2007
Posts: 16
Location: Belgium

Hi, I have an odd flow to create.

I need to transform a complete xml into an xml with escape characters, then I need to put the whole thing within 'some' tags (just start and end of the string I created, which is the escaped XML) and then send it off so that another application can unwrap the one xml tag and then work with the string.

So if this would be the original

Code:

<tag1>
    <tag2/>
    <tag3>
         .......
    </tag3>
</tag1>


then this is what it needs to look like

&lt;tag1&gt;&lt;tag2/&gt;&lt ...... etcetera

I would then put this long stringvalue into one single tag.

Anybody have any idea where to start? I've been searching the net but I can't seem to find it.

Thanks
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Jul 20, 2007 3:31 am    Post subject: Reply with quote

Grand High Poobah

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

Put the embedded XML in a CDATA section?

Write the receiving application so it can properly parse the embedded document?

I'd go with the second - easier for you, eaiser for the receiving application.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
elvis_gn
PostPosted: Fri Jul 20, 2007 3:32 am    Post subject: Reply with quote

Padawan

Joined: 08 Oct 2004
Posts: 1905
Location: Dubai

Hi pyrus,

Do an ASBITSTREAM of the xml with the CCSID and put it into Environment or so, then do a CAST of it to char with CCSID...

I think it'll work, remember doing something similar recently....else work around it....the syntax for the above commands you'll find here on the forum or InfoCenter.

Regards.
Back to top
View user's profile Send private message Send e-mail
pyrus
PostPosted: Fri Jul 20, 2007 3:43 am    Post subject: Reply with quote

Novice

Joined: 20 Jul 2007
Posts: 16
Location: Belgium

Thanks for the tips elvis_gn, I'll try them right away. But I thought I saw something along these lines and I am afraid it's the other way around, I think the escaped characters become the original tags in this way. I will try it anyway.

Vitor.... what do you mean?? I thought the Broker was meant for Integration... It's supposed to make extra development in existing applications unnecessary. Connecting systems in such a way that the only development is within the Websphere scope....?

Correct me if I'm wrong.

If I would do it your way it would be easier for me, but then I would also be out of a job eventually.
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Jul 20, 2007 4:23 am    Post subject: Reply with quote

Grand High Poobah

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

pyrus wrote:
Vitor.... what do you mean?? I thought the Broker was meant for Integration... It's supposed to make extra development in existing applications unnecessary. Connecting systems in such a way that the only development is within the Websphere scope....?

Correct me if I'm wrong.


Depends how much you want to bend the product. I try and add value to the end applications. The method supplied by elvis_qn is perfectly viable.

pyrus wrote:
If I would do it your way it would be easier for me, but then I would also be out of a job eventually.


I work as a consultant; I'm out of a job in a few months whichever way I do it!
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
pyrus
PostPosted: Fri Jul 20, 2007 5:05 am    Post subject: Reply with quote

Novice

Joined: 20 Jul 2007
Posts: 16
Location: Belgium

I work as a consultant too and we try to add as much value to the middleware as we possibly can. Anything they don't do they can't do wrong.

I got lucky though, working for a company that hired me as a consultant for several years AND I get to travel all over the world

So you see it's not my intention to let other people do my work.
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Jul 20, 2007 6:00 am    Post subject: Reply with quote

Grand High Poobah

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

pyrus wrote:
So you see it's not my intention to let other people do my work.


Nothing rude and/or immoral was intended to be inferred & I apologise for any hurt inadvertently caused.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
kimbert
PostPosted: Fri Jul 20, 2007 8:02 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Did you know that all of the broker's XML parsers will automatically escape <, > and & ( and a couple of other characters ) if they occur in the value of an element? Before you write lots of ( slow ) code to do the escaping, you should try this:

1. Convert the xml doc to CHARACTER ( using CAST with CCSID ).
If you are working on the input bitstream, you can just CAST InputRoot.BLOB.BLOB. If your XML doc is in the form of a message tree then you must serialize it using ASBITSTREAM first.
2. Assign the CHARACTER variable to OutputRoot.XMLNSC.dummyRootElement
3. Allow XMLNSC to write the message and do the escaping for you

See what happens - it just might save you a lot of time.
Back to top
View user's profile Send private message
pyrus
PostPosted: Mon Jul 23, 2007 1:44 am    Post subject: Reply with quote

Novice

Joined: 20 Jul 2007
Posts: 16
Location: Belgium

Ok that was what Iwas trying as a matter of fact, but for some reason I get a null value when I try to cast it, at least I think I do. When I declare the variable I want to store it in, I can see it in debug mode, as soon as the cast is done, the variable is gone....

This is what I use:
Code:

DECLARE cdata CHARACTER CAST(InputRoot.BLOB.BLOB AS CHAR CCSID InputRoot.MQMD.CodedCharSetId ENCODING InputRoot.MQMD.Encoding);


I've tried it with both InputRoot.Properties... and InputRoot.MQMD for retreiving the CCSID and ENCODING.

I even only tried the ENCODING because I thought that might have been the error. But still I get no result.
Back to top
View user's profile Send private message
kimbert
PostPosted: Mon Jul 23, 2007 1:53 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Try using a Trace node instead of the debugger. Set the output to 'User Trace'. Enable user trace while executing your flow.
Doing it this way will ensure that
a) you get an accurate picture of your message tree and variables
b) you get to see the full text of any exceptions which are thrown.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Jul 23, 2007 3:13 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

pyrus wrote:
Ok that was what Iwas trying as a matter of fact, but for some reason I get a null value when I try to cast it, at least I think I do. When I declare the variable I want to store it in, I can see it in debug mode, as soon as the cast is done, the variable is gone....

This is what I use:
Code:

DECLARE cdata CHARACTER CAST(InputRoot.BLOB.BLOB AS CHAR CCSID InputRoot.MQMD.CodedCharSetId ENCODING InputRoot.MQMD.Encoding);


I've tried it with both InputRoot.Properties... and InputRoot.MQMD for retreiving the CCSID and ENCODING.

I even only tried the ENCODING because I thought that might have been the error. But still I get no result.


Looks to me like your message is already in a different form. So InputRoot .BLOB.BLOB will return null if you have InputRoot.XMLNS.myns:roottag defined...

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
pyrus
PostPosted: Mon Jul 23, 2007 10:39 pm    Post subject: Reply with quote

Novice

Joined: 20 Jul 2007
Posts: 16
Location: Belgium

Well, good thinking fjb_saper, but that's what I discovered yesterday too. I solved the problem but since I need to be a jack of all trades I immediately had something else to do.

So here is the solution: on the input queue node set the message domain to BLOB and you can work with that much easier. You COULD of course cast it to a blob from what it was, but I only need the blob anyway...

Hope this helps out some other people too.
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 » generating string with escape characters from 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.