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 » reading different inner xml tag in loop and sum

Post new topic  Reply to topic
 reading different inner xml tag in loop and sum « View previous topic :: View next topic » 
Author Message
maxmq
PostPosted: Tue Jan 18, 2011 12:15 pm    Post subject: reading different inner xml tag in loop and sum Reply with quote

Newbie

Joined: 18 Jan 2011
Posts: 3

i want to create a loop from an input which has different xml inner tag which adds the total and sets it to an output totalsales :

InputRoot.XMLNSC.PL.T.TR.LI.SalesfromA.amt.Amount;
InputRoot.XMLNSC.PL.T.TR.LI.BSales.amt.Amount;
InputRoot.XMLNSC.PL.T.TR.LI.SalesC.amt.Amount;
...............

the Sales are different/keep changing..rest all tags are same in the file
i cant even find the cardinality of sales since the tag is different

i am a total newbie....plz help..totally confused
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Jan 18, 2011 12:38 pm    Post subject: Re: reading different inner xml tag in loop and sum Reply with quote

Grand High Poobah

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

maxmq wrote:
the Sales are different/keep changing..rest all tags are same in the file
i cant even find the cardinality of sales since the tag is different


So what you're actually adding are the values of:

InputRoot.XMLNSC.PL.T.TR.some random tag name.amt.Amount?

In that case what you need is a way of making WMB sum amt.Amount irrespective of what's in front it. Like this for instance.

maxmq wrote:
i am a total newbie....


Get some formal training. Push back on whoever's given you this task & point out how complex WMB is.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
kimbert
PostPosted: Tue Jan 18, 2011 3:25 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Sounds like one of those tasks that would be very simple in XPath. /ducks/

I expect the op really wants to stay with ESQL, though. In which case the SELECT function offers hope of a really nice solution:
http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r1m0/topic/com.ibm.etools.mft.doc/ak05620_.htm
Note especially that you can apply the SUM function to the SELECT.

The only question is whether you can use a wildcard ( * ) in the FROM expression. I think you probably can, but mgk is sure to know either way.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Jan 18, 2011 6:21 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

kimbert wrote:
Sounds like one of those tasks that would be very simple in XPath. /ducks/


I'd use an ESQL Select. If, at least, I'd bothered to confirm that ESQL select supports SUM. /ducks/
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Jan 19, 2011 3:32 am    Post subject: Reply with quote

Grand High Poobah

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

You're both quackers.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Jan 19, 2011 3:33 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Vitor wrote:
You're both quackers.

We also both agree that mgk is sure to know either way...
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Jan 19, 2011 3:48 am    Post subject: Reply with quote

Grand High Poobah

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

mqjeff wrote:
Vitor wrote:
You're both quackers.

We also both agree that mgk is sure to know either way...


He always does...
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mgk
PostPosted: Wed Jan 19, 2011 5:00 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Quote:
He always does...
I would not go that far, but I do in this case

This code shows how to do this.

Code:
--set up the data to select from
CREATE LASTCHILD OF Environment DOMAIN 'XMLNSC' NAME 'XMLNSC' ;
SET Environment.XMLNSC.PL.T.TR.LI.SalesfromA.amt.Amount = 42;
SET Environment.XMLNSC.PL.T.TR.LI.BSales.amt.Amount = 43;
SET Environment.XMLNSC.PL.T.TR.LI.SalesC.amt.Amount = 44;

--find out how many sales records there are (cardinality)
SET OutputRoot.XMLNSC.Top.NumberOfSales = CARDINALITY(Environment.XMLNSC.PL.T.TR.LI.*[]);

--get all the records
SET OutputRoot.XMLNSC.Top.All.Data[] = SELECT SALES.amt.Amount FROM Environment.XMLNSC.PL.T.TR.LI.*[] AS SALES ;

--sum the total of all the records   
SET OutputRoot.XMLNSC.Top.Totalsales = SELECT SUM( SALES.amt.Amount ) FROM Environment.XMLNSC.PL.T.TR.LI.*[] AS SALES ;
The above code produces this output message:

Code:
<Top>
  <NumberOfSales>3</NumberOfSales>
  <All>
    <Data><Amount>42</Amount></Data>
    <Data><Amount>43</Amount></Data>
    <Data><Amount>44</Amount></Data>
  </All>
  <Totalsales>129</Totalsales>
</Top>


I hope this helps,
_________________
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
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » reading different inner xml tag in loop and sum
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.