IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Supress Field to print as XML Tag using XML GENERATE


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
naveenkumars

New User


Joined: 17 Jun 2010
Posts: 3
Location: India

PostPosted: Wed Feb 29, 2012 5:18 pm
Reply with quote

Hi,

How can I supress to print Field in XML using XML GENERATE?

Example,
Code:
01 Books
      05  Book               OCCURS 2.
           05 Category                        PIC X(10).
           05 Name            OCCURS 1 PIC X(10).
           05 Aurthor         OCCURS 1 PIC X(10).
           05 Price             OCCURS 1 PIC X(10).

Move 'Buy' TO Category(1).
Move 'ABC' TO Name(1 1).
Move 'XXXX' TO Aurthor(1 1).
Move 434.34 TO Price(1 1).

Move 'Free' TO Category(2).
Move 'XYZ' TO Name(2 1).
Move 'XXXX' TO Aurthor(2 1).

XML GENERATE XMLOUT FROM Books
      WITH ATTRIBUTES
END-XML.


The above code will display XML as
<Books>
<Book Category="Buy">
<Name>ABC</Name>
<Aurthor>XXXX</Aurthor>
<Price>434.34</Price>
</Book>
<Book Category="Free">
<Name>XYZ</Name>
<Aurthor>XXXX</Aurthor>
<Price> </Price>
</Book>
</Books>

I do not want to print <Price> Tag in XML for attribute 'Category=Free'.

Is there anyway to do this using XML GENERATE?
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Thu Mar 01, 2012 12:02 am
Reply with quote

No idea but surely the price is 0.00. By specifying a value it shows that you have not forgotten to code for price in this instance.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Thu Mar 01, 2012 1:24 am
Reply with quote

I agree with Nic. However, if you are hung up on doing this, consider declaring another structure named Free-Books without the price and if price is zero, use this structure instead of the Books.
Back to top
View user's profile Send private message
naveenkumars

New User


Joined: 17 Jun 2010
Posts: 3
Location: India

PostPosted: Thu Mar 01, 2012 8:49 pm
Reply with quote

Thank you for your replies.

In some cases, few tags shouldnt be displayed in XML. But unfotunately, whatever we define in the Working sotrage structure, the same format is genreated as XML tags using XML Generator in Cobol.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Mar 02, 2012 2:03 am
Reply with quote

naveenkumars wrote:

In some cases, few tags shouldnt be displayed in XML. But unfotunately, whatever we define in the Working sotrage structure, the same format is genreated as XML tags using XML Generator in Cobol.



maybe that is why agkshirsagar suggested defining different structures in Working-Storage.......

which IMUHO is clever.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Generate random number from range of ... COBOL Programming 3
No new posts JCL sortcard to print only the records DFSORT/ICETOOL 11
No new posts Join 2 files according to one key field. JCL & VSAM 3
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
Search our Forums:

Back to Top