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 » Generating XML tags from variable values

Post new topic  Reply to topic
 Generating XML tags from variable values « View previous topic :: View next topic » 
Author Message
kishankumar.v
PostPosted: Wed Jan 16, 2002 2:48 am    Post subject: Reply with quote

Apprentice

Joined: 26 Nov 2001
Posts: 47

Hi All,
I have the following XML message.
kishan
kumar

This should be converted to
kishan
kumar

The value has to be kept as-is but the name of the XML tag has to be changed. I have the mapping in a database. So i should get the tag name into a ESQL variable .. get the tag name from database into a variable .. Iam not sure as to how to achieve this. Is there anyway to do this.

TIA,
Regards,
Kishan
Back to top
View user's profile Send private message Send e-mail
NickB
PostPosted: Wed Jan 16, 2002 3:23 am    Post subject: Reply with quote

Centurion

Joined: 20 May 2001
Posts: 107
Location: Zurich Financial Services

Kishan

You need to re-post this question, making sure that you tick the "Disable HTML on this Post".
Back to top
View user's profile Send private message
kishankumar.v
PostPosted: Wed Jan 16, 2002 5:44 am    Post subject: Reply with quote

Apprentice

Joined: 26 Nov 2001
Posts: 47

Hi All,
Iam reposting this....

I have the following XML message.
<first_name>kishan</first_name>
<second_name>kumar</second_name>

This should be converted to
<fname>kishan </fname>
<sname>kumar</sname>

The value has to be kept as-is but the name of the XML tag has to be changed. I have the mapping in a database. So i should get the tag name into a ESQL variable .. get the tag name from database into a variable .. Iam not sure as to how to achieve this. Is there anyway to do this.

TIA,
Regards,
Kishan
Back to top
View user's profile Send private message Send e-mail
zpat
PostPosted: Thu Jan 17, 2002 3:48 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5849
Location: UK

Changing XML names is easy enough - I think what you are asking is can you make the names themselves variables and read from a table.

I'm no ESQL expert, but you should look at the EVAL function and also REFERENCE variables (the latter only in WMQI 2.1).
Back to top
View user's profile Send private message
kishankumar.v
PostPosted: Thu Jan 17, 2002 4:01 am    Post subject: Reply with quote

Apprentice

Joined: 26 Nov 2001
Posts: 47

Hi,
The requirement is somewhat simillar to what you had expected..I need to get the names of the xml tags in to the variable.

<first_name>kishan</first_name>
<second_name>kumar</second_nmae>

select tag2name from x where tag1name='first_name';

I can hardcode the where clause each time .. but i dont want to do that..is there any method by which I can get all the XML Tag names into ESQL Variable one by one..so that inside the for loop from first tag to last tag get the tag name and from database get the tag name to be replaced.
Hope Iam clear in my requirement....
Please help...

TIA,
Regards,
Kishan


Back to top
View user's profile Send private message Send e-mail
zpat
PostPosted: Thu Jan 17, 2002 4:15 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5849
Location: UK

I think you can use a SELECT statement on a message tree to avoid hard-coding the names.

Also you navigate a message tree with reference variables and the MOVE function in WMQI 2.1

I am sure this can be done though.
Back to top
View user's profile Send private message
kishankumar.v
PostPosted: Thu Jan 17, 2002 4:35 am    Post subject: Reply with quote

Apprentice

Joined: 26 Nov 2001
Posts: 47

Hi,
Iam sorry Iam not able to gather the solution since Iam new to mqseries...Also
Iam using Integrator version 2.0.1
Can you explain more on the SELECT statement to get the tag names without hardcoding and
how to navigate ?

TIA,
Regards,
Kishan
Back to top
View user's profile Send private message Send e-mail
mpuetz
PostPosted: Thu Jan 17, 2002 8:14 am    Post subject: Reply with quote

Centurion

Joined: 05 Jul 2001
Posts: 149
Location: IBM/Central WebSphere Services

Hi,

let's suppose you have table named MAP
which has the following columns

MAP_ID, MAP_FROM, MAP_TO
1,first_name, fname
1,last_name,lname

with Primary Keys MAP_ID, MAP_FROM

and you would like to code general ESQL
which then performs the mapping equivalent to

SET OutputRoot.XML.Msg.fname = InputBody.Msg.first_name;
SET OutputRoot.XML.Msg.lname = InputBody.Msg.last_name;

The code should be general enough, that you don't have to touch the ESQL to extend your mapping to new fields, but just add entries to the database table.
I hope I am guessing correctly that this is
what you want.

First of all: this going to be slow, so if your flows are performance critical, better hardwire your mappings, like expressed above.

However the following peace of ESQL (not error checked) should do the trick:

SET OutputDestinationList.Map[] = SELECT A.MAP_FROM,A.MAP_TO FROM Database.MAP AS A WHERE A.MAP_ID = 1;

SET I = 1;
WHILE (I < CARDINALITY(OutputDestinationList.Map[]) DO
EVAL('SET OutputRoot.XML.Msg.' || OutputDestinationList.Map[I].MAP_TO || ' = InputBody.Msg.' || OutputDestinationList.Map[I].MAP_FROM || ';');
SET I = I + 1;
END WHILE;

Note, that this is already optimized in such a way that it only needs a single SELECT from your mapping table using a MAP_ID key, instead of selecting each mapping pair by a separate select statement.
Of course this only works if you know which fields to expect in your input message. If you don't know a priori which fields are contained in the input message you could modify the code like this:

DECLARE map_from CHAR;
DECLARE map_to CHAR;

SET I = 1;
WHILE (I < CARDINALITY(InputBody.Msg.(XML.tag)[]) DO
SET map_from = FIELDNAME(InputBody.Msg.(XML.tag)[I]);
SET map_to = THE(SELECT ITEM A.MAP_TO FROM OutputDestinationList.Map[] AS A WHERE A.MAP_FROM = map_from);

EVAL('SET OutputRoot.XML.Msg.' || map_to || ' = InputBody.Msg.' || map_from || ';');
SET I = I + 1;
END WHILE;

Hope that's helpful.

_________________
Mathias Puetz

IBM-EMEA AIM Services
MQ/WMQI Specialist


[ This Message was edited by: mpuetz on 2002-01-17 08:19 ]
Back to top
View user's profile Send private message
zpat
PostPosted: Thu Jan 17, 2002 8:27 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5849
Location: UK

That looks superb.

Of course another way might be to use two MRM defined XML message sets with different XML tag names defined for the same field in each set.

You would have to update the message sets when new fields were added, but all you have to do in a compute node would be to set the output message set id and the MRM would generate the appropriate tags for you.
Back to top
View user's profile Send private message
Miriam Kaestner
PostPosted: Thu Jan 17, 2002 9:04 am    Post subject: Reply with quote

Centurion

Joined: 26 Jun 2001
Posts: 103
Location: IBM IT Education Services, Germany

Instead of using the EVAL function (which has big performance overhead), you could also use FIELDNAME to get the old XML tags,
and SET with NAME parameter to change field name. Example:
OutputRoot.XML.oldTag NAME='newTag';
Back to top
View user's profile Send private message Send e-mail
kishankumar.v
PostPosted: Thu Jan 17, 2002 9:18 pm    Post subject: Reply with quote

Apprentice

Joined: 26 Nov 2001
Posts: 47

Hi,
Thanks folks...That was really helpful. I was going through ESQL reference yesterday .. so Iam able to understand what was discussed...
Thanks again...

Regards,
Kishan
Back to top
View user's profile Send private message Send e-mail
kishankumar.v
PostPosted: Fri Jan 18, 2002 1:58 am    Post subject: Reply with quote

Apprentice

Joined: 26 Nov 2001
Posts: 47

Hi Folks,
A small clarification. I have seen at many places and even here when the solution was given....OutputDestinationList is used for using temporary data..
Is this the only way for storing such data or in other words what makes one go
for OutputDestinationList while its purpose is something else..Is there no array definitions possible in ESQL to store data temporarily. Please throw more light on the use of OutputDestinationList here.

Regards,
Kishan
Back to top
View user's profile Send private message Send e-mail
kirani
PostPosted: Fri Jan 18, 2002 10:27 am    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

Kishan,

In lower version of MQSI (2.0.x) mostly people use DestinationList to store temporary data in the message. Destination list is ment to store MQDestinationList, RouterList and Temporary variables. If data is stored in a local variable, it can not be accessed by other nodes.

There are some supportpacs out there to meet different requirements,
You can also use WKSPACE parser to store temporary data that is shared within the message or you can use Postit plug-in to share data across messages or message flows.

In WMQI 2.1 they have added a new Environment treee to provide 'scratchpad area'.

Hope this helps.

Kiran
Back to top
View user's profile Send private message Visit poster's website
mpuetz
PostPosted: Fri Jan 18, 2002 4:29 pm    Post subject: Reply with quote

Centurion

Joined: 05 Jul 2001
Posts: 149
Location: IBM/Central WebSphere Services

Hi all,

since Miriam mentioned it, EVAL can really
cause performance problems, especially if
called within a loop as suggested in my previous posting. However there is nothing
which pervents you to put the whole loop inside the EVAL statement which makes the perfomance hit almost negligible.



[ This Message was edited by: mpuetz on 2002-01-18 16:32 ]
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 » Generating XML tags from variable values
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.