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 » Problem searching for a field value in XML message.

Post new topic  Reply to topic
 Problem searching for a field value in XML message. « View previous topic :: View next topic » 
Author Message
rajaram
PostPosted: Tue Mar 23, 2004 6:32 am    Post subject: Problem searching for a field value in XML message. Reply with quote

Acolyte

Joined: 02 Jan 2004
Posts: 53

Hi,
I have a problem searching an XML message.
I have a field(element) called <at id='222'> which occurs multiple times in another field(element) called <class id> which also occurs many times.
I did this:

DECLARE T REFERENCE TO "InputBody"."XX"."class"[];

SET "OutputRoot"."MRM"."AAA" = THE(SELECT ITEM R."value" FROM T."at"[] AS R WHERE R."id" = '123');


But this doesnt seem to work as the select statement searches only the first <class id > element
The aboc statement will not wrok for the following kind of message
eg:
<class id=1>
<at id="222"></at>
</class>
<class id = 2>
<at id ="123"></at>
</class>


If i want to search for an <at id> in the entire XML message. Is there any other way i can try?

I could use while loop but there are many mappings...which makes my code highly inefficient.

Please Help
Back to top
View user's profile Send private message
fjcarretero
PostPosted: Tue Mar 23, 2004 6:42 am    Post subject: Reply with quote

Voyager

Joined: 13 Oct 2003
Posts: 88

You could try nesting the select statements

Something like:
Code:
SET "OutputRoot"."MRM"."AAA" = THE(SELECT (SELECT ITEM R."value" FROM T."at"[] AS R WHERE R."id" = '123') FROM "InputBody"."XX"."class"[] AS T);


I haven't tested it

Hope this helps
Felipe
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Mar 23, 2004 6:51 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

If your Input message is in the XML domain (rather than XML modelled in MRM), then you'll need to indicate that "id" is an XML.Attribute, and not just a plain XML.Element.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
Missam
PostPosted: Tue Mar 23, 2004 7:39 am    Post subject: Reply with quote

Chevalier

Joined: 16 Oct 2003
Posts: 424

what jeff is referring to is right.you need to perform a check on the Attribue rather that the content of at[].try this one
Code:
SET "OutputRoot"."XML"."AAA" = THE(SELECT R."value" FROM "InputBody"."Message"."class"[] as T,T."at"[] AS R WHERE R.(XML.Attribute)"id" = '123');
Back to top
View user's profile Send private message
rajaram
PostPosted: Tue Mar 23, 2004 10:11 am    Post subject: BOTH THE CODES ARE NOT WORKING Reply with quote

Acolyte

Joined: 02 Jan 2004
Posts: 53

SET "OutputRoot"."MRM"."AAA" = THE(SELECT (SELECT ITEM R."value" FROM T."at"[] AS R WHERE R."id" = '123') FROM "InputBody"."XX"."class"[] AS T);


THIS STATEMENT WOULD SELECT content of R."value" first and try to search it in "inputbody"."xx"."class",which obviously is not present.


------------------------------------------



SET "OutputRoot"."XML"."AAA" = THE(SELECT R."value" FROM "InputBody"."Message"."class"[] as T,T."at"[] AS R WHERE R.(XML.Attribute)"id" = '123');



this would not solve my problem as the select statement still searches only the first <class>
Back to top
View user's profile Send private message
Missam
PostPosted: Tue Mar 23, 2004 11:09 am    Post subject: Reply with quote

Chevalier

Joined: 16 Oct 2003
Posts: 424

Quote:
this would not solve my problem as the select statement still searches only the first <class>


I don't think the search ends with only the first <class> in your message.Did you tried it...?

the problem here is not about using

Code:
SET "OutputRoot"."MRM"."AAA" = THE(SELECT (SELECT ITEM R."value" FROM T."at"[] AS R WHERE R."id" = '123') FROM "InputBody"."XX"."class"[] AS T);


or

Code:
SET "OutputRoot"."XML"."AAA" = THE(SELECT R."value" FROM "InputBody"."Message"."class"[] as T,T."at"[] AS R WHERE R.(XML.Attribute)"id" = '123');


The Point here is you need to look into Attribute of the field rather that conent of the field to satisy your search requirement.
Back to top
View user's profile Send private message
rajaram
PostPosted: Tue Mar 23, 2004 10:08 pm    Post subject: Let me put my problem in simple words Reply with quote

Acolyte

Joined: 02 Jan 2004
Posts: 53

XML message:
<top level>
<class id=1>
<at id="222">
<text id= "456">Hello World</text>
</at>
</class>
<class id = 2>
<at id ="123">
<text id= "789">Hi </text>
</at>
</class>
<class id=3>
.
.
.
.
.
</top level>


I need to search for the <text> and not the attribute of <text>...based on the value of attribute 'id' of 'at'..ie
if at.(XML.Attribute)id = '123' then
set output.mrm.aaa = at.text
end if
Now the problem is i need to search for this in every class without using a while loop.
How do i do that??
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 » Problem searching for a field value in XML message.
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.