Author |
Message
|
shalabh1976 |
Posted: Thu Sep 19, 2013 9:09 pm Post subject: ESQL code generator |
|
|
 Partisan
Joined: 18 Jul 2002 Posts: 381 Location: Gurgaon, India
|
I have a requirement to generate large XML (>500 lines) as output from my code (There at 15-20 different XML's). The output XML samples are available. Now it will be helpful if I have a skeleton ESQL code for the basic XML available. Is there any ESQL code generator available that gives an ESQL string as output for a given XML as input. I can then customize this skeleton code but the major code generation would have been done.
For e.g. Input XML (very simple) is <Root><Data>123</Data></Root> will give an output SET OutputRoot.XMLNSC.Root.Data = '123'; _________________ Shalabh
IBM Cert. WMB V6.0
IBM Cert. MQ V5.3 App. Prog.
IBM Cert. DB2 9 DB Associate |
|
Back to top |
|
 |
Simbu |
Posted: Thu Sep 19, 2013 9:25 pm Post subject: Re: ESQL code generator |
|
|
 Master
Joined: 17 Jun 2011 Posts: 289 Location: Tamil Nadu, India
|
shalabh1976 wrote: |
I have a requirement to generate large XML (>500 lines) as output from my code (There at 15-20 different XML's). The output XML samples are available. Now it will be helpful if I have a skeleton ESQL code for the basic XML available. Is there any ESQL code generator available that gives an ESQL string as output for a given XML as input. I can then customize this skeleton code but the major code generation would have been done.
For e.g. Input XML (very simple) is <Root><Data>123</Data></Root> will give an output SET OutputRoot.XMLNSC.Root.Data = '123'; |
Below is the steps I followed when I had the same scenario some months before to generate ESQL code.
1. Open RfhUtil
2. Open File
3. GOTO Data
4. Choose Data Format as PARSED
5. Copy the message Data into TestPad
6. Prefix each line with 'SET OutputRoot.XMLNSC.'
7. Postfix each line with ';'
8. Remove unwanted code. |
|
Back to top |
|
 |
shalabh1976 |
Posted: Thu Sep 19, 2013 11:54 pm Post subject: |
|
|
 Partisan
Joined: 18 Jul 2002 Posts: 381 Location: Gurgaon, India
|
Good starting point, but many lines do not have any assignment so if I add ; at the end ESQL editor throws an error - for e.g.
methodResponse.params.param.value.struct.member
methodResponse.params.param.value.struct.member.name='accountValue1'
methodResponse.params.param.value.struct.member.value
Adding a ';' after each line only makes it valid for line 2. _________________ Shalabh
IBM Cert. WMB V6.0
IBM Cert. MQ V5.3 App. Prog.
IBM Cert. DB2 9 DB Associate |
|
Back to top |
|
 |
shalabh1976 |
Posted: Fri Sep 20, 2013 12:28 am Post subject: |
|
|
 Partisan
Joined: 18 Jul 2002 Posts: 381 Location: Gurgaon, India
|
Fixed the problem by making lines not having = end with ='';
However a new problem was discovered for repeating tags. Since the code does not address repeating elements if a tag appears again it overwrites the previous occurrence. _________________ Shalabh
IBM Cert. WMB V6.0
IBM Cert. MQ V5.3 App. Prog.
IBM Cert. DB2 9 DB Associate |
|
Back to top |
|
 |
Tibor |
Posted: Fri Sep 20, 2013 12:35 am Post subject: |
|
|
 Grand Master
Joined: 20 May 2001 Posts: 1033 Location: Hungary
|
And what do you think about writing ESQL code for doing this? In ESQL, you can easily access all the XML elements / attributes. |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Sep 20, 2013 1:15 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
|
Back to top |
|
 |
dogorsy |
Posted: Fri Sep 20, 2013 3:23 am Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
shalabh1976 wrote: |
Fixed the problem by making lines not having = end with ='';
However a new problem was discovered for repeating tags. Since the code does not address repeating elements if a tag appears again it overwrites the previous occurrence. |
use CREATE LASTCHILD instead of SET |
|
Back to top |
|
 |
shalabh1976 |
Posted: Sun Sep 22, 2013 10:31 pm Post subject: |
|
|
 Partisan
Joined: 18 Jul 2002 Posts: 381 Location: Gurgaon, India
|
Same result with CREATE LASTCHILD. _________________ Shalabh
IBM Cert. WMB V6.0
IBM Cert. MQ V5.3 App. Prog.
IBM Cert. DB2 9 DB Associate |
|
Back to top |
|
 |
dogorsy |
Posted: Sun Sep 22, 2013 11:25 pm Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
shalabh1976 wrote: |
Same result with CREATE LASTCHILD. |
Can you please be more specific ? What did you do ? What do you mean with same result ? |
|
Back to top |
|
 |
shalabh1976 |
Posted: Mon Sep 23, 2013 12:57 am Post subject: |
|
|
 Partisan
Joined: 18 Jul 2002 Posts: 381 Location: Gurgaon, India
|
Replaced all SET Output..................... with CREATE LASTCHILD OF Output.............
Replaced all = with VALUE
Here is a partial XML :
Code: |
<?xml version="1.0" encoding="utf-8"?>
<methodResponse>
<params>
<param>
<value>
<struct>
<member>
<name>accountValue1</name>
<value>
<string>8626015</string>
</value>
</member>
<member>
<name>creditClearanceDate</name>
<value>
<dateTime.iso8601>20290426T12:00:00+0000</dateTime.iso8601>
</value>
</member>
<member>
<name>currency1</name>
<value>
<string>INR</string>
</value>
</member>
<member> |
Equivalent lines from RFHUtil :
Code: |
methodResponse
methodResponse.params
methodResponse.params.param
methodResponse.params.param.value
methodResponse.params.param.value.struct
methodResponse.params.param.value.struct.member
methodResponse.params.param.value.struct.member.name='accountValue1'
methodResponse.params.param.value.struct.member.value
methodResponse.params.param.value.struct.member.value.string='8626015'
methodResponse.params.param.value.struct.member
methodResponse.params.param.value.struct.member.name='creditClearanceDate'
methodResponse.params.param.value.struct.member.value
methodResponse.params.param.value.struct.member.value.dateTime.iso8601='20290426T12:00:00+0000'
methodResponse.params.param.value.struct.member
methodResponse.params.param.value.struct.member.name='currency1'
methodResponse.params.param.value.struct.member.value
methodResponse.params.param.value.struct.member.value.string='INR'
methodResponse.params.param.value.struct.member
methodResponse.params.param.value.struct.member.name='dedicatedAccountInformation'
methodResponse.params.param.value.struct.member.value
methodResponse.params.param.value.struct.member.value.array
methodResponse.params.param.value.struct.member.value.array.data
methodResponse.params.param.value.struct.member.value.array.data.value
methodResponse.params.param.value.struct.member.value.array.data.value.struct
methodResponse.params.param.value.struct.member.value.array.data.value.struct.member
methodResponse.params.param.value.struct.member.value.array.data.value.struct.member.name='dedicatedAccountID'
methodResponse.params.param.value.struct.member.value.array.data.value.struct.member.value
methodResponse.params.param.value.struct.member.value.array.data.value.struct.member.value.i4='1'
methodResponse.params.param.value.struct.member.value.array.data.value.struct.member
methodResponse.params.param.value.struct.member.value.array.data.value.struct.member.name='dedicatedAccountValue1'
methodResponse.params.param.value.struct.member.value.array.data.value.struct.member.value
methodResponse.params.param.value.struct.member.value.array.data.value.struct.member.value.string='4200'
methodResponse.params.param.value.struct.member.value.array.data.value.struct.member
methodResponse.params.param.value.struct.member.value.array.data.value.struct.member.name='expiryDate'
methodResponse.params.param.value.struct.member.value.array.data.value.struct.member.value
methodResponse.params.param.value.struct.member.value.array.data.value.struct.member.value.dateTime.iso8601='20130929T12:00:00+0000'
|
Now I replaced all lines with no = at the end to have =''; also added SET OutputRoot.XMLNSC. _________________ Shalabh
IBM Cert. WMB V6.0
IBM Cert. MQ V5.3 App. Prog.
IBM Cert. DB2 9 DB Associate |
|
Back to top |
|
 |
dogorsy |
Posted: Mon Sep 23, 2013 1:03 am Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
shalabh1976 wrote: |
Replaced all SET Output..................... with CREATE LASTCHILD OF Output.............
Replaced all = with VALUE |
In that case you cannot get the same result. As you are IBM certified, you probably know how to run a user trace and debug your code. |
|
Back to top |
|
 |
lancelotlinc |
Posted: Mon Sep 23, 2013 3:05 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
dogorsy wrote: |
shalabh1976 wrote: |
Replaced all SET Output..................... with CREATE LASTCHILD OF Output.............
Replaced all = with VALUE |
In that case you cannot get the same result. As you are IBM certified, you probably know how to run a user trace and debug your code. |
I have some doubt about this. _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
shalabh1976 |
Posted: Mon Sep 23, 2013 4:02 am Post subject: |
|
|
 Partisan
Joined: 18 Jul 2002 Posts: 381 Location: Gurgaon, India
|
I'll let that pass jedi knight. _________________ Shalabh
IBM Cert. WMB V6.0
IBM Cert. MQ V5.3 App. Prog.
IBM Cert. DB2 9 DB Associate |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Sep 23, 2013 9:13 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Please note that with the notation you gave us:
Quote: |
methodResponse.params.param.value.struct.member.value.dateTime.iso8601='20290426T12:00:00+0000' |
you have no way of creating the right tag for the timestamp:
The featured notation would mean:
Code: |
<methodResponse>
<Params>
<param>
<value>
<struct>
<member>
<value>
<dateTime>
<iso8601>20290426T12:00:00+0000</iso801>
</dateTime>
</value>
........ |
To use dateTime.iso8601 as a tag name you would need to use "dateTime.iso8601" (with double quotes around it...)
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
dogorsy |
Posted: Mon Sep 23, 2013 2:35 pm Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
fjb_saper wrote: |
Please note that with the notation you gave us:
Quote: |
methodResponse.params.param.value.struct.member.value.dateTime.iso8601='20290426T12:00:00+0000' |
you have no way of creating the right tag for the timestamp:
The featured notation would mean:
Code: |
<methodResponse>
<Params>
<param>
<value>
<struct>
<member>
<value>
<dateTime>
<iso8601>20290426T12:00:00+0000</iso801>
</dateTime>
</value>
........ |
To use dateTime.iso8601 as a tag name you would need to use "dateTime.iso8601" (with double quotes around it...)
Have fun  |
pardon me ?! where do you see "dateTime.iso8601" as a tag name ? there is a dateTime tag and an iso8601 , nothing wrong with either... |
|
Back to top |
|
 |
|