|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Anonymous Field Reference in ESQL |
« View previous topic :: View next topic » |
Author |
Message
|
dev |
Posted: Thu Mar 28, 2002 11:34 am Post subject: |
|
|
Apprentice
Joined: 11 Oct 2001 Posts: 30
|
I have various XML messages comming in with similar structure but Root element, lets say messages are:
Msg 1:
<?xml version="1.0" encoding="UTF-8"?>
<AAA>
<Header>
<Topic></Topic>
<MessageSequence></MessageSequence>
</Header>
</AAA>
Msg 2:
<?xml version="1.0" encoding="UTF-8"?>
<BBB>
<Header>
<Topic></Topic>
<MessageSequence></MessageSequence>
</Header>
</BBB>
.
.
.
.
Msg n:
<?xml version="1.0" encoding="UTF-8"?>
<NNN>
<Header>
<Topic></Topic>
<MessageSequence></MessageSequence>
</Header>
</NNN>
While sending message out in Compute node I write for root element AAA:
SET "OutputRoot"."XML"."AAA"."Header"."Topic" = "InputBody"."AAA"."Header"."MessageSequence";
or for root element NNN
SET "OutputRoot"."XML"."NNN"."Header"."Topic" = "InputBody"."NNN"."Header"."MessageSequence";
If I need to refer Root element of InputBody, so I can write one statement like:
SET "OutputRoot"."XML"."NNN"."Header"."Topic" = "InputBody".*[2]."Header"."MessageSequence";
Similar, if I need to refer Output message's root element what shoud I refer?
I want something like this but I know that syntactically wrong.
SET "OutputRoot"."XML".(FIELDNAME("InputBody".*[2]))."Header"."Topic" = "InputBody".*[2]."Header"."MessageSequence";
Any help?
|
|
Back to top |
|
 |
dev |
Posted: Thu Mar 28, 2002 2:21 pm Post subject: |
|
|
Apprentice
Joined: 11 Oct 2001 Posts: 30
|
I got it working, solution is:
EVAL('SET "OutputRoot"."XML".' ||(FIELDNAME(InputBody.(XML.tag)[1]))|| '."Header"."Topic" = "InputBody".*[2]."Header"."MessageSequence";');
Thanks |
|
Back to top |
|
 |
kirani |
Posted: Thu Mar 28, 2002 2:48 pm Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
try this ...
DECLARE myroot CHAR;
SET myroot = FIELDNAME(InputBody.*[1]);
EVAL( 'SET OutputRoot.XML.' || myroot || '.Header.Topic = InputBody.*[1].Header.MessageSequence');
|
|
Back to top |
|
 |
kolban |
Posted: Fri Mar 29, 2002 9:04 am Post subject: |
|
|
 Grand Master
Joined: 22 May 2001 Posts: 1072 Location: Fort Worth, TX, USA
|
I try and avoid EVAL wherever I can. It is too expensive for my taste. How about the following:
Code: |
declare inputDocRef reference to InputRoot.XML.*[1];
create firstchild of OutputRoot.XML NAME fieldname(inputDocRef);
declare outputDocRef reference to OutputRoot.XML.*[1];
set outputDocRef.Header.Topic = inputDocRef.Header.MessageSequence;
|
For additional info on referencies, see http://www.mqseries.net/phpBB/viewtopic.php?topic=2045&forum=7&6 |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|