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 » Manipulating XML

Post new topic  Reply to topic Goto page 1, 2  Next
 Manipulating XML « View previous topic :: View next topic » 
Author Message
angka
PostPosted: Wed Sep 03, 2008 2:25 am    Post subject: Manipulating XML Reply with quote

Chevalier

Joined: 20 Sep 2005
Posts: 406

Hi,

Below my xml

<Message>
<MessageHeader>
<MsgID/>
.....
</MessageHeader>
<MessageBody ServiceID = "123">
<Payload xmlns:xsd ....>
............

</Payload>
</MessageBody>
</Message>

I parsed the incoming message as XML and i need to set the <Payload> to OutputRoot.XML. below my code

Set OutputRoot.XML = InputRoot.XML.Message.MessageBody;

using this code, i got the ServiceID too, how to i set only the <Payload> child to OutputRoot.XML?

Thanks
Back to top
View user's profile Send private message
kimbert
PostPosted: Wed Sep 03, 2008 3:01 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Please do not use the XML domain because
a) it is deprecated.
b) your input XML contains namespaces

Code:
SET OutputRoot.XMLNSC.Payload = InputRoot.XMLNSC.Message.MessageBody.Payload;
Back to top
View user's profile Send private message
angka
PostPosted: Wed Sep 03, 2008 3:44 am    Post subject: Reply with quote

Chevalier

Joined: 20 Sep 2005
Posts: 406

Hi,

i can't use this
SET OutputRoot.XMLNSC.Payload = InputRoot.XMLNSC.Message.MessageBody.Payload;
because the <Payload> tag is unknown.. i.e. it is another xml schema? the <Payload> tag is an example, it could be any element name. What i need is to retrieve everything after tag <MessageBody> but not it attributes.

Thank you
Back to top
View user's profile Send private message
kimbert
PostPosted: Wed Sep 03, 2008 4:22 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

So you want the child tag under <MessageBody>?

XMLNSC makes this a little more difficult than it should, but that is being corrected. For now, I suggest that you switch to the XMLNS domain, and use this:
Code:
SET OutputRoot.XMLNS.Payload = InputRoot.XMLNS.Message.MessageBody.(XML.Element)*[1];
Back to top
View user's profile Send private message
Gaya3
PostPosted: Wed Sep 03, 2008 4:26 am    Post subject: Reply with quote

Jedi

Joined: 12 Sep 2006
Posts: 2493
Location: Boston, US

is this possible on XMLNSC (i didnt test this)

SET OutputRoot.XMLNSC.Payload = InputRoot.XMLNSC.Message.MessageBody.[>];
_________________
Regards
Gayathri
-----------------------------------------------
Do Something Before you Die
Back to top
View user's profile Send private message
Gemz
PostPosted: Wed Sep 03, 2008 5:06 am    Post subject: Reply with quote

Centurion

Joined: 14 Jan 2008
Posts: 124

I have used in my code like

SET OutputRoot.XMLNSC.Payload = InputRoot.XMLNSC.Message.MessageBody.*[<];

So I hope that ll also work.
Back to top
View user's profile Send private message
kimbert
PostPosted: Wed Sep 03, 2008 5:08 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Gaya3: You need to make sure that you are selecting the tag, rather than some whitespace which might have occurred before or after the tag. That's why I'm testing for XML.Element.
By default XMLNSC discards whitespace before and after tags ( mixed content ) so your code is probably safe.
Back to top
View user's profile Send private message
angka
PostPosted: Wed Sep 03, 2008 7:21 am    Post subject: Reply with quote

Chevalier

Joined: 20 Sep 2005
Posts: 406

Hi,

Can I set it this way without the .Payload as shown below:
SET OutputRoot.XMLNS = InputRoot.XMLNS.Message.MessageBody.(XML.Element)*[1];

this is because the tag <Payload> can be <a>, <b> or <c>. i wanna assigned the whole of the child tag under <MessageBody> minus the attributes to OutputRoot.XMLNS therefore my MQ body would only contend the whole <a>

Thanks
Back to top
View user's profile Send private message
kimbert
PostPosted: Wed Sep 03, 2008 8:00 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Of course you can. If you do it this way, the result with either be an empty output message ( so you should be careful of that ), or an output message in which the first child tag under MessageBody is the root tag of the output message.
Back to top
View user's profile Send private message
angka
PostPosted: Wed Sep 03, 2008 8:03 am    Post subject: Reply with quote

Chevalier

Joined: 20 Sep 2005
Posts: 406

Hi,

it will not be empty because the payload is the application data. ya that is wat i wan the first child tag under MessageBody is the root tag of my output message. i will try it tmr.

Thanks
Back to top
View user's profile Send private message
angka
PostPosted: Wed Sep 03, 2008 7:46 pm    Post subject: Reply with quote

Chevalier

Joined: 20 Sep 2005
Posts: 406

Hi,

I tried the below code:
SET OutputRoot.XMLNS = InputRoot.XMLNS.Message.MessageBody.(XML.Element)*[1];

the InputRoot.XMLNS.Message.MessageBody is returning null value. why is this so? i tried (parsing to XMLNS)

SET charTest = InputRoot.XMLNS.Message.MessageBody.ServiceId;

and i got null also. but when i tried (parsing to XML)

SET charTest = InputRoot.XML.Message.MessageBody.ServiceId;

i got the value. What is wrong?

Thanks
Back to top
View user's profile Send private message
marko.pitkanen
PostPosted: Wed Sep 03, 2008 9:54 pm    Post subject: Reply with quote

Chevalier

Joined: 23 Jul 2008
Posts: 440
Location: Jamsa, Finland

Hi angka,

Perhaps you could try Trace -node before your CN with pattern ${Root} to see how your message have been parsed to the message tree.

And use debug trace(mqsichangetrace, mqsireadlog & mqsiformatlog) for you EG and search the detailed information about you code execution.

Marko
Back to top
View user's profile Send private message Visit poster's website
angka
PostPosted: Wed Sep 03, 2008 10:15 pm    Post subject: Reply with quote

Chevalier

Joined: 20 Sep 2005
Posts: 406

Hi,

Ok.. i will retrieve the trace later.

BTW, is there a way to specify the tag as a variable for e.g,

SET OutputRoot.XMLNS.{variable} = InputRoot.....

Thanks.
Back to top
View user's profile Send private message
Gaya3
PostPosted: Wed Sep 03, 2008 10:27 pm    Post subject: Reply with quote

Jedi

Joined: 12 Sep 2006
Posts: 2493
Location: Boston, US

angka wrote:

BTW, is there a way to specify the tag as a variable for e.g,
SET OutputRoot.XMLNS.{variable} = InputRoot.....


yes, you can do like this, you have to define the variable in advance
_________________
Regards
Gayathri
-----------------------------------------------
Do Something Before you Die
Back to top
View user's profile Send private message
angka
PostPosted: Wed Sep 03, 2008 11:23 pm    Post subject: Reply with quote

Chevalier

Joined: 20 Sep 2005
Posts: 406

Hi,

you mean as below?

SET charTest = 'PayLoad1';

SET OutputRoot.XMLNS.{charTest} = InputRoot.XMLNS.Message.MessageBody.(XML.Element)*[1];

Thanks
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 » Manipulating 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.