Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Specification of XML tag attribute values

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Feargal FitzPatrick

New User


Joined: 11 Jul 2012
Posts: 5
Location: Republic of Ireland

PostPosted: Wed Feb 13, 2013 4:36 pm    Post subject: Specification of XML tag attribute values
Reply with quote

We need to create an XML document in a COBOL program. Our approach is to build a data structure in a COPYBOOK and use the XML GENERATE command to create the XML document.

In the COPYBOOK, the COBOL field names used are the same as XML tag values we are required to use (ISO standard values).

One field in the XML layout that has an attribute or property value assigned.

Code:
         <Ntry>
            <Amt Ccy="SEK">105678.50</Amt>
            <CdtDbtInd>CRDT</CdtDbtInd>


The COPYBOOK specifies the corresponding COBOL fields as

Code:
05 Ntry
   07 Amt
   07 CdtDbtInd


How in the COPYBOOK should the attribute value (Ccy="SEK") be specified ?
Back to top
View user's profile Send private message

Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Wed Feb 13, 2013 6:17 pm    Post subject:
Reply with quote

If I understood what you mean, possibly this will help, though I might be totally wrong:
Code:
05 Ntry
   07 Amt  PIC X(09) VALUE "CCY='SEK'".
   07 CdtDbtInd
Back to top
View user's profile Send private message
Feargal FitzPatrick

New User


Joined: 11 Jul 2012
Posts: 5
Location: Republic of Ireland

PostPosted: Wed Feb 13, 2013 6:25 pm    Post subject: Reply to: Specification of XML tag attribute values
Reply with quote

Thank you

I may not have been as clear as I should have been. My understanding of the XML GENERATE is that it will 'read' ..

Code:
05 Ntry.
   07 Amt          PIC 9(9).99.


.. and generate some xml as ..

Code:
<Ntry><Amt>999999999.99</Amt></Ntry


My question is how do I code the COPYBOOK so that the xml is generated with Ccy="SEK" included ?
Back to top
View user's profile Send private message
Ed Goodman

Active Member


Joined: 08 Jun 2011
Posts: 556
Location: USA

PostPosted: Wed Feb 13, 2013 9:00 pm    Post subject:
Reply with quote

OK, look at this:

http://itknowledgeexchange.techtarget.com/itanswers/enterprise-cobol-xml-attributes/

Then look in the Programming Guide:
Code:

01 doc pic x(512).
01 docSize pic 9(9) binary.
01 G.
     05 A pic x(3) value "aaa".
     05 B.
          10 C pic x(3) value "ccc".
          10 D pic x(3) value "ddd".
     05 E pic x(3) value "eee".


Normal XML generate will produce:
Code:

<G><A>aaa</A><B><C>ccc</C><D>ddd</D></B><E>eee</E></G>


XML GENERATE WITH ATTRIBUTES will produce:
Code:

<G A="aaa" E="eee"><B C="ccc" D="ddd"></B></G>


The answer provided in the above link shows a workaround to make COBOL mix up the formats by adding an 'OCCURS 1' to those elements that you need to be child elements instead of attributes. Pretty clever really.

You may not need to do that depending on the rest of your layout.

Just in case that link above is dead when you're reading this, I'm copying the text here:

Quote:

One way I have found to make this work is by using an occurs of 1 on fields that you want to be generated as child elements. So the example used in this question would look like this.
Code:

01 Customer.
     05 C-Type PIC X(10).
     05 Name occurs 1 PIC X(20).
     05 Address occurs 1 PIC X(20)
     05 City occurs 1 PIC X(20)
     05 State occurs PIC X(02)
     05 Zip occurs 1 PIC X(05).

You then use the with attributes option in your xml generate. Elements with an occurs clause do not generate as attributes. The only drawback to this solution is that you have to use a subscript whenever you use one of the fields with a occurs clause.
Back to top
View user's profile Send private message
Feargal FitzPatrick

New User


Joined: 11 Jul 2012
Posts: 5
Location: Republic of Ireland

PostPosted: Fri Feb 15, 2013 3:04 pm    Post subject:
Reply with quote

Thanks for that
We'll try this approach and I'll update this thread with the outcome.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts BI,TO=ZD Changing Values Tyler Dunbar DFSORT/ICETOOL 4 Tue Jul 25, 2017 12:12 am
No new posts Sorting of hex values Saurabh_mi DFSORT/ICETOOL 11 Thu May 25, 2017 3:49 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Compare two files and subtract values ameetmund DFSORT/ICETOOL 7 Fri Mar 31, 2017 3:35 pm
No new posts Check Binary Values for symbols gandikk CA Products 3 Tue Mar 21, 2017 5:11 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us