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 » XML in ESQL, how?

Post new topic  Reply to topic
 XML in ESQL, how? « View previous topic :: View next topic » 
Author Message
Carl Bloy
PostPosted: Tue Aug 23, 2005 8:16 am    Post subject: XML in ESQL, how? Reply with quote

Acolyte

Joined: 16 Dec 2003
Posts: 69
Location: England

Hi all,

I was wondering if anyone can explain whether it's possible to represent the following XML in ESQL?

<RESY >
<ADDRESSNUMBER>11</ADDRESSNUMBER>
<ADDRESSINDICATOR>P</ADDRESSINDICATOR>
<NAMESCOUNT>2</NAMESCOUNT>
<NAMESEQUENCENUMBER>01</NAMESEQUENCENUMBER>
<DATEFROM_DD>23</DATEFROM_DD>
<DATEFROM_MM>08</DATEFROM_MM>
<DATEFROM_CCYY>2001</DATEFROM_CCYY>
<DATETO_DD>23</DATETO_DD>
<DATETO_MM>08</DATETO_MM>
<DATETO_CCYY>2003</DATETO_CCYY>
<NAMESEQUENCENUMBER>11</NAMESEQUENCENUMBER>
<DATEFROM_DD>23</DATEFROM_DD>
<DATEFROM_MM>08</DATEFROM_MM>
<DATEFROM_CCYY>2001</DATEFROM_CCYY>
<DATETO_DD>23</DATETO_DD>
<DATETO_MM>08</DATETO_MM>
<DATETO_CCYY>2003</DATETO_CCYY>
</RESY>

Many thanks
CArl.
_________________
Regards
Carl
Back to top
View user's profile Send private message Visit poster's website
djeripo
PostPosted: Tue Aug 23, 2005 8:24 am    Post subject: Reply with quote

Master

Joined: 25 Jan 2004
Posts: 225

Simple XML one - one mapping.Assuming the XML you posted comes as Input to Compute node.

SET OutputRoot.XML.Resy.AddressNumber = InputRoot.XML.RESY.ADDRESSNUMBER;

----------
----------


Last edited by djeripo on Tue Aug 23, 2005 8:24 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
jefflowrey
PostPosted: Tue Aug 23, 2005 8:24 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Yes. This should be straight forward, bearing in mind that there are multiple instances of several fields.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
Carl Bloy
PostPosted: Wed Aug 24, 2005 2:07 am    Post subject: It's not that simple... Reply with quote

Acolyte

Joined: 16 Dec 2003
Posts: 69
Location: England

It's not as easy as doing one to one mapping, i'm not sure how to map the repeating elements?

If you map them as one to one then the second one ovwerwites the first one.

If you map them with an array index then the order of the elements changes?
_________________
Regards
Carl
Back to top
View user's profile Send private message Visit poster's website
javaforvivek
PostPosted: Wed Aug 24, 2005 2:56 am    Post subject: Reply with quote

Master

Joined: 14 Jun 2002
Posts: 282
Location: Pune,India

Carl Bloy wrote:
Quote:
i'm not sure how to map the repeating elements?


It depends upon how many elements are repeating. From your message I see that elements from 'NAMESEQUENCENUMBER' to 'DATETO_CCYY' form a set of related elements. This set repeats itself n number of times.
Now, If you want to copy entire input message to output message then there is one simple statement
Code:
 OutputRoot = InputRoot



But if you want to copy only selective (and repeating) elements from input to output then there are several different ways to do it:
Code:

DECLARE NAMESEQUENCENUMBERCard INTEGER CARDINALITY (InputRoot.XML.RESY.NAMESEQUENCENUMBER[]);
DECLARE i INTEGER 1;
CREATE FIELD OutputRoot.XML.RESY;
CREATE FIRSTCHILD OF OutputRoot.XML.RESY NAME 'ADDRESSNUMBER' VALUE InputRoot.XML.RESY.ADDRESSNUMBER;
WHILE ( i <= NAMESEQUENCENUMBERCard)  DO
CREATE LASTCHILD OF OutputRoot.XML.RESY NAME 'NAMESEQUENCENUMBER' VALUE InputRoot.XML.RESY.NAMESEQUENCENUMBER[i];
CREATE LASTCHILD OF OutputRoot.XML.RESY NAME 'DATEFROM_DD' VALUE InputRoot.XML.RESY.DATEFROM_DD[i];
CREATE LASTCHILD OF OutputRoot.XML.RESY NAME 'DATEFROM_MM' VALUE InputRoot.XML.RESY.DATEFROM_MM[i];
SET i = i +1;
      
END WHILE;

You can use REFERENCE to both input and output roots for looping purpose. And more efficient code can be written based on what I have coded here.
For further details of 'Handling Large XML Messages' please see:

http://publib.boulder.ibm.com/infocenter/wbihelp/index.jsp?topic=/com.ibm.etools.mft.doc/ac16740_.htm
_________________
Vivek
------------------------------------------------------
...when you have eliminated the impossible, whatever remains, however improbable, must be the truth.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Carl Bloy
PostPosted: Wed Aug 24, 2005 6:57 am    Post subject: Many thanks Reply with quote

Acolyte

Joined: 16 Dec 2003
Posts: 69
Location: England

Vivek,

Many thanks for your response, exactly what we were looking for works a treat.

Much appreciated!!

Regards
Carl.
_________________
Regards
Carl
Back to top
View user's profile Send private message Visit poster's website
Lillian
PostPosted: Wed Oct 12, 2005 11:09 pm    Post subject: Reply with quote

Centurion

Joined: 15 Apr 2002
Posts: 102

Hi Vivek

i am trying to get a similar output but where the repeating type is the parent of two children. ie

<NAMESEQUENCENUMBER>
<DATEFROM_DD>23</DATEFROM_DD>
<DATEFROM_MM>08</DATEFROM_MM>
</NAMESEQUENCENUMBER>
<NAMESEQUENCENUMBER>
<DATEFROM_DD>23</DATEFROM_DD>
<DATEFROM_MM>08</DATEFROM_MM>
</NAMESEQUENCENUMBER>
<NAMESEQUENCENUMBER>
<DATEFROM_DD>23</DATEFROM_DD>
<DATEFROM_MM>08</DATEFROM_MM>
</NAMESEQUENCENUMBER>


I keep getting the reference point of creating the next sibling wrong.
Back to top
View user's profile Send private message
javaforvivek
PostPosted: Thu Oct 13, 2005 12:39 am    Post subject: Reply with quote

Master

Joined: 14 Jun 2002
Posts: 282
Location: Pune,India

Lillian,
First of all your XML is NOT valid XML, because it doesn't have the root tag. I have assumed that your output will be encapsulated in <Message> Root tag. Here is the code for the same output message that you have described:
Code:

CREATE FUNCTION Main() RETURNS BOOLEAN
   BEGIN
       CALL CopyMessageHeaders();
      -- CALL CopyEntireMessage();
      CREATE FIELD OutputRoot.XML.Message;
      CREATE FIRSTCHILD OF OutputRoot.XML.Message DOMAIN ('XML') NAME 'NAMESEQUENCENUMBER';
      CREATE FIRSTCHILD OF OutputRoot.XML.Message.NAMESEQUENCENUMBER[1] NAME 'DATEFROM_DD' VALUE '23';
      CREATE LASTCHILD OF OutputRoot.XML.Message.NAMESEQUENCENUMBER[1] NAME 'DATEFROM_MM' VALUE '08';
      CREATE NEXTSIBLING OF OutputRoot.XML.Message.NAMESEQUENCENUMBER[1] NAME 'NAMESEQUENCENUMBER';
      CREATE FIRSTCHILD OF OutputRoot.XML.Message.NAMESEQUENCENUMBER[2] NAME 'DATEFROM_DD' VALUE '24';
      CREATE LASTCHILD OF OutputRoot.XML.Message.NAMESEQUENCENUMBER[2] NAME 'DATEFROM_MM' VALUE '08';
      CREATE NEXTSIBLING OF OutputRoot.XML.Message.NAMESEQUENCENUMBER[2] NAME 'NAMESEQUENCENUMBER';
      CREATE FIRSTCHILD OF OutputRoot.XML.Message.NAMESEQUENCENUMBER[3] NAME 'DATEFROM_DD' VALUE '25';
      CREATE LASTCHILD OF OutputRoot.XML.Message.NAMESEQUENCENUMBER[3] NAME 'DATEFROM_MM' VALUE '08';
      RETURN TRUE;
   END;

which gives the output of
<Message>
<NAMESEQUENCENUMBER>
<DATEFROM_DD>23</DATEFROM_DD>
<DATEFROM_MM>08</DATEFROM_MM>
</NAMESEQUENCENUMBER>
<NAMESEQUENCENUMBER>
<DATEFROM_DD>24</DATEFROM_DD>
<DATEFROM_MM>08</DATEFROM_MM>
</NAMESEQUENCENUMBER>
<NAMESEQUENCENUMBER>
<DATEFROM_DD>25</DATEFROM_DD>
<DATEFROM_MM>08</DATEFROM_MM>
</NAMESEQUENCENUMBER>
</Message>

I have assumed that NAMESEQUENCENUMBER is repeated three times only. But if you are not sure of the repeat count, then you may have to use the WHILE loop ( or whatever looping you can think of) after creating first occurrence of NAMESEQUENCENUMBER.
_________________
Vivek
------------------------------------------------------
...when you have eliminated the impossible, whatever remains, however improbable, must be the truth.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Lillian
PostPosted: Thu Oct 13, 2005 1:03 am    Post subject: Reply with quote

Centurion

Joined: 15 Apr 2002
Posts: 102

Thanks again... It works.
I added the snippet into a loop and it was supposed to be within a root element as assumed.
Back to top
View user's profile Send private message
javaforvivek
PostPosted: Thu Oct 13, 2005 4:30 am    Post subject: Reply with quote

Master

Joined: 14 Jun 2002
Posts: 282
Location: Pune,India

Please Please go through the link I had mentioned in my earlier posts. It is very useful in teaching how you can handle large XML Messages.
You need to understand:
What do the NEXTSIBLING and FIRST/LASTCHILD mean.
How the CREATE statements are more performance friendly than direct SET statements.
How to build an output message tree from input message tree.
I have found ESQL as the easiest part of WBIMB to learn and message modelling concepts (especially CWF and TDS Wire Formats) as the hardest part to learn...
_________________
Vivek
------------------------------------------------------
...when you have eliminated the impossible, whatever remains, however improbable, must be the truth.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » XML in ESQL, how?
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.