Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 Extend the decimal values in DIVISION Balaryan DFSORT/ICETOOL 3 Thu Oct 05, 2017 4:05 pm
No new posts Working with hex values in Filemanage... Emile Straker IBM Tools 0 Tue Sep 12, 2017 1:42 am
No new posts DB2 NULL Values display V S Amarendra Reddy DB2 3 Thu Sep 07, 2017 6:59 pm
No new posts Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm
No new posts BI,TO=ZD Changing Values Tyler Dunbar DFSORT/ICETOOL 4 Tue Jul 25, 2017 12:12 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us