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 » XML processing in ESQL - simple(?) doubt

Post new topic  Reply to topic
 XML processing in ESQL - simple(?) doubt « View previous topic :: View next topic » 
Author Message
AgentSmith
PostPosted: Fri Dec 05, 2003 5:48 am    Post subject: XML processing in ESQL - simple(?) doubt Reply with quote

Novice

Joined: 19 Nov 2003
Posts: 19

Hi,
This is a simple question, but I lack knowledge.
I have an input XML that comes from database like this:
<CHANGELOGDATA>
<CLIENT oid="1234">
<FIRST_NM old="ALF" new="ALFRED" op="UPDATE"/>
</CLIENT>

<CLIENT_ADDR oid="10">
<CAD_CD old="PRI" new="LEGAL" op="UPDATE"/>
</CLIENT_ADDR>

<ADDRESS oid="101">
<ADDR_LN1 old="EFGH" new="WALL ST" op="UPDATE"/>
</ADDRESS>
</CHANGELOGDATA>

The tags CLIENT, CLIENT_ADDR, ADDRESS etc., are table names and are unknown to me. There could be any number of such tags inside the root tag CHANGELOGDATA.

I need to retrieve the names of these tags and put it in an ESQL Array, for further processing.

Is there anyway to get these anonymous tag names via ESQL?

Please help.

Regards,
AgentSmith
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Fri Dec 05, 2003 6:36 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

So you want to loop over each direct child of the CHANGELOGDATA tag, and then do something?
Code:
 declare aRef reference to InputRoot.XML.CHANGELOGDATA;
move aRef FIRSTCHILD;
while (lastmove(aRef)) do
   --do something
   -- the variable aRef points to a child of CHANGELOGDATA
   move aRef NEXTSIBLING;
end while;


See chapter 2 of the ESQL reference for more information on working with anonymous field references and dynamic references.

ESQL doesn't really have arrays (everything is a tree or a scalar) and all variables that you declare are scalars (single items, numbers or strings). You can create lists (which are really trees) in the Environment or the LocalEnvironment.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
mgk
PostPosted: Fri Dec 05, 2003 7:20 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Depending on the version of the product you are using, you can use the FIELDNAME function to obtain the name of a field
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
Missam
PostPosted: Tue Dec 09, 2003 10:55 am    Post subject: Reply with quote

Chevalier

Joined: 16 Oct 2003
Posts: 424

Hi
Both JeffLowrey and mkg are correct,you can combine both answers and get you required like this
Code:

declare aRef reference to InputRoot.XML.CHANGELOGDATA;
declare flsname character;
declare index Integer;
Set index = 1;
move aRef FIRSTCHILD;
while (lastmove(aRef)) do
   --do something
   -- the variable aRef points to a child of CHANGELOGDATA
   Set fldname = FILEDNAME(aRef);
   Set OutputLocalEnvironment.ArrayInfo[index] = fldname;
   Set index = index + 1;
   move aRef NEXTSIBLING;
end while;

Like this you can place all tag names in an array
Thanx,
Sam.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Dec 09, 2003 11:12 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

IamSam wrote:
Code:
Set OutputLocalEnvironment.ArrayInfo[index] = fldname;

Like this you can place all tag names in an array
Except, again, that's not an array. It's a tree, where particular elements are accessed by an index. ArrayInfo[3] is the third child (from the left, I think) of ArrayInfo, not element 3 of an array. Array elements don't have siblings, parents, or children. ESQL fields do.

The reason why I'm stressing that there are no arrays is because of performance issues. When you use an index into a tree, in order to get at the data the system has to walk the entire tree up to that point. So it works it's way down the tree to the last non-indexed element, and then it enumerates through the children of that element until it's gotten to the right number.

This is why you get much better performance using references than you do indexes - references only have to do any traversal relative to the reference instead of the root of the tree.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
v_venugopalan
PostPosted: Thu Dec 18, 2003 5:13 am    Post subject: Reply with quote

Novice

Joined: 25 Nov 2003
Posts: 12
Location: INDIA

Hi All,
Thx for all your suggestions. I used field reference and it worked!!
I created a new tree hierarchy for output.
Thx everybody.

Regards,
AgentSmith
_________________
VV
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 » XML processing in ESQL - simple(?) doubt
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.