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 » ESQL question

Post new topic  Reply to topic
 ESQL question « View previous topic :: View next topic » 
Author Message
schroederms
PostPosted: Fri May 07, 2004 4:51 am    Post subject: ESQL question Reply with quote

Disciple

Joined: 21 Jul 2003
Posts: 169
Location: IA

I'm wanting to grab the deepest vale of the tag <EXAMPLE_XML> within my XML, without any success. This tag may occur many times , this is where my problem.

Can anyone help ?

Thanks.

THIS IS WHAT THE INPUT LOOKS LIKE:

<APPLICATION_SERVICES>
<ACTION>INSERT/MODIFY</ACTION>
<APP_ID>application name here</APP_ID>
<FUNCTION>DEFAULT</FUNCTION>
<INSTANCE>DEF</INSTANCE>
<CLIENT>999</CLIENT>
<REALTIME>Y</REALTIME>
<SERVICEQ>application queue</SERVICEQ>
<SERVICEQMGR>application queue mgr</SERVICEQMGR>
<DESCRIPTION>this is a test</DESCRIPTION>
<EXAMPLEXML>
<EXAMPLE_XML>
<EXAMPLE_XML>
<EXAMPLE_XML>
<EXAMPLE_XML>
<EXAMPLE_XML>
<REQUEST>
<BOGUS></BOGUS>
</REQUEST>
</EXAMPLE_XML>
</EXAMPLE_XML>
</EXAMPLE_XML>
</EXAMPLE_XML>
</EXAMPLE_XML>
</EXAMPLEXML>
</APPLICATION_SERVICES>



THIS IS WHAT I WANT THE OUTPUT TO LOOK LIKE:

<APPLICATION_SERVICES>
<ACTION>INSERT/MODIFY</ACTION>
<APP_ID>application name here</APP_ID>
<FUNCTION>DEFAULT</FUNCTION>
<INSTANCE>DEF</INSTANCE>
<CLIENT>999</CLIENT>
<REALTIME>Y</REALTIME>
<SERVICEQ>application queue</SERVICEQ>
<SERVICEQMGR>application queue mgr</SERVICEQMGR>
<DESCRIPTION>this is a test</DESCRIPTION>
<EXAMPLEXML>
<EXAMPLE_XML>
<REQUEST>
<BOGUS></BOGUS>
</REQUEST>
</EXAMPLE_XML>
</EXAMPLEXML>

</APPLICATION_SERVICES>
Back to top
View user's profile Send private message
Missam
PostPosted: Fri May 07, 2004 5:48 am    Post subject: Reply with quote

Chevalier

Joined: 16 Oct 2003
Posts: 424

Try This

Code:
DECLARE inptr REFERENCE TO InputBody."APPLICATION_SERVICES";

SET OutputRoot.XML."APPLICATION_SERVICES".ACTION = inptr.ACTION;
SET OutputRoot.XML."APPLICATION_SERVICES"."APP_ID" = inptr."APP_ID";
SET OutputRoot.XML."APPLICATION_SERVICES".FUNCTION = inptr.FUNCTION;
SET OutputRoot.XML."APPLICATION_SERVICES".INSTANCE = inptr.INSTANCE;
SET OutputRoot.XML."APPLICATION_SERVICES".CLIENT = inptr.CLIENT;
SET OutputRoot.XML."APPLICATION_SERVICES".REALTIME = inptr.REALTIME;
SET OutputRoot.XML."APPLICATION_SERVICES".SERVICEQ = inptr.SERVICEQ;
SET OutputRoot.XML."APPLICATION_SERVICES".SERVICEQMGR = inptr.SERVICEQMGR;

MOVE inptr TO inptr."EXAMPLEXML"."EXAMPLE_XML";

WHILE LASTMOVE(inptr) = TRUE DO
MOVE inptr TO inptr."EXAMPLE_XML";
END WHILE;

SET OutputRoot.XML."APPLICATION_SERVICES".EXAMPLEXML."EXAMPLE_XML".REQUEST.BOGUS = inptr.REQUEST.BOGUS;
Back to top
View user's profile Send private message
fschofer
PostPosted: Fri May 07, 2004 5:48 am    Post subject: Reply with quote

Knight

Joined: 02 Jul 2001
Posts: 524
Location: Mainz, Germany

Hi, is the name of EXAMPLE_XML known and always the same ?

However, my solution may work without knowing the tag names.

Its untested, so it may have some syntax errors.

Please try out the two following to versions,
they should do the same but the second may be incorrect.

Code:
DECLARE myref REFERENCE TO InputRoot.XML.APPLICATION_SERVICES.EXAMPLEXML;

WHILE ( LASTMOVE(myref) = TRUE ) AND ( FIELDNAME(myref.*[1].*[1]) <> 'REQUEST' ) ) DO
  MOVE myref FIRSTCHILD;
END WHILE;

SET OutputRoot.XML.APPLICATION_SERVICES.EXAMPLEXML.*[1] = myref.*[1];



Code:
DECLARE myref REFERENCE TO InputRoot.XML.APPLICATION_SERVICES.EXAMPLEXML;

WHILE ( LASTMOVE(myref) = TRUE ) AND ( FIELDNAME(myref.*[1]) <> 'REQUEST' ) ) DO
  MOVE myref FIRSTCHILD;
END WHILE;

SET OutputRoot.XML.APPLICATION_SERVICES.EXAMPLEXML.*[1] = myref;
Back to top
View user's profile Send private message Send e-mail
jefflowrey
PostPosted: Fri May 07, 2004 5:55 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Both fschofer's example (at least one of them) and Missam's example should work.

But they both have certain assumptions behind them. Missam's example assumes that your nested tags are always called EXAMPLE_XML. Fschofer's example assumes that you want to walk down the "left most" side of the tree - always descend the first child.

If your requirements do not fit either of those two assumptions, you will need to change these examples to fit.

But what you're trying to do is a basic tree-walking procedure - so you should be able to find an algorithm that does what you want in some language or another and convert that to ESQL.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
Missam
PostPosted: Fri May 07, 2004 6:09 am    Post subject: Reply with quote

Chevalier

Joined: 16 Oct 2003
Posts: 424

Yes Jeff is right.Coding Always Changes with requirements.

Mr schroederms provided the input and told that how he wants to look the output and also based on his statement

Quote:

I'm wanting to grab the deepest vale of the tag <EXAMPLE_XML> within my XML


I assumed that a simple walk to the deepest element and a copy from there would solve his problem.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Fri May 07, 2004 6:16 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Missam wrote:
Yes Jeff is right.Coding Always Changes with requirements.

Mr schroederms provided the input and told that how he wants to look the output and also based on his statement

I assumed that a simple walk to the deepest element and a copy from there would solve his problem.


Right, and there's nothing wrong with that.

I just wanted to make sure that schroederms understood the assumptions behind your code so that he adjust as needed.

And remind everyone that ESQL is just another programming language, and the logical message model is just another tree structure...
_________________
I am *not* the model of the modern major general.
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 » ESQL question
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.