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
 
Supress Field to print as XML Tag using XML GENERATE

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Supress Field to print as XML Tag using XML GENERATE
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: 1932
Location: UK

PostPosted: Thu Mar 01, 2012 12:02 am    Post subject:
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: 686
Location: Earth

PostPosted: Thu Mar 01, 2012 1:24 am    Post subject:
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    Post subject:
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: 6970
Location: porcelain throne

PostPosted: Fri Mar 02, 2012 2:03 am    Post subject:
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    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
This topic is locked: you cannot edit posts or make replies. Incrementing current time field by 30... arunsoods DFSORT/ICETOOL 11 Thu Oct 26, 2017 3:22 pm
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Partial color change of a field in CI... waseem0424 CICS 5 Fri Sep 29, 2017 7:56 pm
No new posts Generate public-private key in batch ... vasanthz All Other Mainframe Topics 6 Fri Sep 15, 2017 9:20 am
No new posts Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am

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