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 add a new fld in the output xml pub/sub

Post new topic  Reply to topic
 how to add a new fld in the output xml pub/sub « View previous topic :: View next topic » 
Author Message
beth_carlin
PostPosted: Wed Jun 28, 2006 7:42 pm    Post subject: how to add a new fld in the output xml pub/sub Reply with quote

Acolyte

Joined: 08 Jun 2004
Posts: 64

please teach me how to insert a new field in the xml output msg in pubsub using wmqi 2.1 ?


I have this simple code in the compute node which extracts the last closing tag as TOPIC
then pass the entire input XML msg thru without any change to the Output and it works ok

-- code begins----

DECLARE C INTEGER;
SET C = CARDINALITY(InputRoot.*[]);
DECLARE I INTEGER;
SET I = 1;
WHILE I < C DO
SET OutputRoot.*[I] = InputRoot.*[I];
SET I=I+1;
END WHILE;
-- Enter SQL below this line. SQL above this line might be regenerated, causing any modifications to be lost.
SET OutputRoot.MQMD.Format = 'MQHRF2 ' ;
Set OutputRoot.MQRFH2.(MQRFH2.Field)CodedCharSetId = 1208;
Set OutputRoot.MQRFH2.(MQRFH2.Field)Encoding = 546;
Set OutputRoot.MQRFH2.(MQRFH2.Field)Format = 'MQSTR ';

SET OutputRoot.MQRFH2.psc.Command='Publish';
DECLARE CNT INTEGER;
DECLARE TOPIC CHARACTER;
SET CNT = CARDINALITY(InputRoot.XML.*[]);
-- topic is the last root tag in the tree
SET TOPIC = FIELDNAME(InputRoot.XML.*[CNT]);
IF TOPIC = '' THEN
SET TOPIC = FIELDNAME(InputRoot.XML.*[CNT-1]);
END IF;

SET OutputRoot.MQRFH2.psc.Topic='application/testtopic/' || TOPIC;

SET OutputRoot.XML = InputBody;

--code ends


-------This is my current input and output message ------

<employeeinfo>
<name>John Smith </name>
<address> 123 Bell st </address>
</employeeinfo>
---------------------------------------------

This is my question
I would like to add one extra field to the output message to be like this
<employeeinfo>
<name>John Smith </name>
<address>123 Bell st </address>
<country>ca</country>
</<employeeinfo>
and
WITHOUT hardcoding the 'employeeinfo ' in the
SET OutputRoot.XML.employeeinfo.country
that is
I would like to avoid hardcoding 'employeeinfo' using this statement below if possible

SET OutputRoot.XML.employeeinfo.country ='ca';

The reason I would like to avoid hardcoding 'employeeinfo' because employeeinfo is a value extracted from the input message and it changes
for different input messages

I also tried this but run into error
EVAL('SET OutputRoot.XML.'|| TOPIC || '.country' = 'ca');

Would you pleae teach me how to do this ?



Thanks very much
beth carlin
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Jul 04, 2006 6:10 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Please teach yourself what the {} means.
_________________
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 » how to add a new fld in the output xml pub/sub
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.