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 » How to set the value of an output xml element w/ attribute?

Post new topic  Reply to topic
 How to set the value of an output xml element w/ attribute? « View previous topic :: View next topic » 
Author Message
hobybrown
PostPosted: Wed Sep 11, 2002 8:38 am    Post subject: How to set the value of an output xml element w/ attribute? Reply with quote

Newbie

Joined: 11 Sep 2002
Posts: 3

I am trying to set the value of an output xml element with an attribute.
Example:
<outerelement>
<element attrib="AAAA">xxxx</element>
<element attrib="BBBB">yyyy</element>
<outerelement>

would like to change to:
<outerelement>
<element attrib="AAAA">xxxx</element>
<element attrib="BBBB">zzzz</element>
<outerelement>

Is there a way to do this using a simple 'SET' statement in ESQL? I have tried the following without success:
SET OutputRoot.XML.outerelement."element attrib=""BBBB""" = 'zzzz';
Back to top
View user's profile Send private message
lbrett
PostPosted: Wed Sep 11, 2002 9:25 am    Post subject: Reply with quote

Novice

Joined: 24 Jan 2002
Posts: 20

For your example use

SET OutputRoot.XML.outerelement[2]='zzzz';

If you want to make the change based on value of the element attribute then use:

DECLARE A INTEGER;
DECLARE B INTEGER;
SET A = CARDINALITY(InputBody.outerelement[]);
SET B=1;

WHILE B <= A DO
IF (InputBody.outerelement[B].(XML.attr)attrib='BBBB') THEN
SET OutputRoot.XML.outerelement[B]='zzzz';
END IF;
SET B=B+1;
END WHILE;
Back to top
View user's profile Send private message
philip.baker
PostPosted: Wed Sep 11, 2002 10:29 am    Post subject: Reply with quote

Voyager

Joined: 21 Mar 2002
Posts: 77
Location: Baker Systems Consulting, Inc. - Tampa

Or for a 'variation on a theme':


SET OutputRoot = InputRoot;
-- Enter SQL below this line. SQL above this line might be regenerated, causing any modifications to be lost.
DECLARE EIndex INTEGER;
DECLARE OEIndex INTEGER;
DECLARE Temp CHAR;
DECLARE TEST CHAR;
SET TEST = 'BBBB';
SET OEIndex = 1;
SET EIndex = 1;
IF (InputRoot.XML.outerelement IS NOT NULL) THEN
WHILE OEIndex <= CARDINALITY(InputRoot.XML.outerelement[]) DO
IF (InputRoot.XML.outerelement[OEIndex].element IS NOT NULL) THEN
WHILE EIndex <= CARDINALITY(InputRoot.XML.outerelement[OEIndex].element[]) DO
SET Temp = InputRoot.XML.outerelement[OEIndex].element[EIndex].(XML.attr)attrib;
IF ( Temp = TEST ) THEN
SET OutputRoot.XML.outerelement[OEIndex].element[EIndex]='zzzz';
SET OutputRoot.XML.outerelement[OEIndex].element[EIndex].(XML.attr)attrib='BBBB';
END IF;
SET EIndex = EIndex +1;
END WHILE;
END IF;
SET OEIndex = OEIndex +1;
END WHILE;
END IF;

Regards,
Phil
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
lbrett
PostPosted: Wed Sep 11, 2002 10:42 am    Post subject: Reply with quote

Novice

Joined: 24 Jan 2002
Posts: 20

Sorry... my ESQL is a little incorrect You are trying to set the value of element and not outerelement.

============================

For your example use

SET OutputRoot.XML.outerelement.element[2]='zzzz';

If you want to make the change based on value of the element attribute then use:

DECLARE A INTEGER;
DECLARE B INTEGER;
SET A = CARDINALITY(InputBody.outerelement.element[]);
SET B=1;
WHILE B <= A DO
IF (InputBody.outerelement.element[B].(XML.attr)attrib='BBBB') THEN
SET OutputRoot.XML.outerelement.element[B]='zzzz';
END IF;
SET B=B+1;
END WHILE;
Back to top
View user's profile Send private message
hobybrown
PostPosted: Wed Sep 11, 2002 12:16 pm    Post subject: Reply with quote

Newbie

Joined: 11 Sep 2002
Posts: 3

Ibrett,
Thank you for your quick reply. Thanks to your initial lead, I finally got it to work. I had just figured out that your esql was slightly incorrect and was going to post the correction, but you have beaten me to it. Thank you for your help. Could not have figured it out without your help.
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 » How to set the value of an output xml element w/ attribute?
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.