|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
xml to copybook |
« View previous topic :: View next topic » |
Author |
Message
|
aks |
Posted: Fri Jul 19, 2002 2:15 am Post subject: xml to copybook |
|
|
Voyager
Joined: 19 Jul 2002 Posts: 84
|
I am transforming XML into a COBOL copybook in a compute node.
Would someone please help me with ESQL syntax to map repeating XML elements into MRM fields:
Part of my xml looks like this:
...
<factors>
<factor>blah 2</factor>
<factor>blah 1</factor>
</factors>
...
There can be any number of factor elements, but it must map to a copybook structure that allows a fixed number of fields, in my current copybook, 13. That is
...
100 07 FACTORS
200 09 FACTOR01
300 09 FACTOR02
400 09 FACTOR03
... .....
1000 09 FACTOR13
1100 07 FACTORS
So I want to map the first <factor> to FACTOR01, the 2nd to FACTOR02 and so forth. If there are less than 13 <factor> tags, for example 8, then the remaining 5 MRM fields, FACTOR09 to FACTOR13 just need to be set to blank (''). If there are more than 13 <factor> elements, then the rest get thrown away.
I know I would be able to do this eventually, but since I am new to MQSI and I have a tight deadline, any help would be appreciated
Thanks
Alan |
|
Back to top |
|
 |
kirani |
Posted: Fri Jul 19, 2002 8:15 am Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
Alan,
You could first create a default value (space ' ') for elements, FACTOR01...13 in MRM-CWF. Then use some while loop to iterate over input repeating XML elements and based on counter switch to different branches, where you will assign input XML element to output MRM field. For example, if the cunter is 3, you should switch to statement,
SET OutputRoot.MRM."FACTOR03" = InputRoot.XML...factors.factor[CNT];
where CNT = 3.
Alternative to SWITCH statement, you could use EVAL statement to dynamically generate MRM FIELD names (FACTOR01....FACTOR13).
Hope this helps. _________________ Kiran
IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries
|
|
Back to top |
|
 |
Miriam Kaestner |
Posted: Thu Jul 25, 2002 3:04 am Post subject: |
|
|
Centurion
Joined: 26 Jun 2001 Posts: 103 Location: IBM IT Education Services, Germany
|
Instead of the EVALUATE statement which performs poorly, you could also use dynamic field name notation {}, e.g.
SET OutputRoot.MRM.{'FACTOR'||CAST(CNT AS CHAR)} = InputRoot.XML...factors.factor[CNT]; |
|
Back to top |
|
 |
kirani |
Posted: Thu Jul 25, 2002 11:40 am Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
didn't know about {...} in Fieldnames. I guess, this was introduced in CSD2.
Thanks for the information Miriam! _________________ Kiran
IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries
|
|
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
|
|
|
|