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

Suppressing empty values after XML-GENERATE statement


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

New User


Joined: 26 Feb 2008
Posts: 2
Location: Pune

PostPosted: Fri Aug 28, 2009 11:34 am
Reply with quote

Hello,

I am learning to use XML GENERATE in COBOL which works fine. Some of my elements in the structure for XML conversion have empty values after they are mapped to an input file. For example, the XML structure is

01 cardRecord.
05 addrLine1 PIC X(20).
05 addrLine2 PIC X(20).
05 name PIC X(30).
05 businessName PIC X(26).

Here,after mapping this to the i/p XML file, I have non-empty values in addrLine1,addrLine2,name whereas my businessName field has empty values.

Is there any way for me to prevent the tag having empty values not getting displayed after XML-GENERATE statement like this ?

<businessName> </businessName>

Please let me know if any more details are required.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Aug 28, 2009 5:28 pm
Reply with quote

I just read the COBOL Language Reference manual (link at the top of the page) on XML GENERATE. Elementary variables are trimmed during processing but they are always left at one space. Hence, by what COBOL is doing, the variable is not empty -- it contains a space (which probably becomes the entire field of spaces).

Second, when the data is completely processed what do you think will be in the field -- there must be some value (LOW-VALUES, SPACES, ABC COMPANY, or whatever)? COBOL has no concept of an empty variable -- they always have some value (the variable might contain garbage, but it isn't empty because COBOL doesn't know empty). I think you need to consider what you want the variable to contain rather than attempting to do things the language makes impossible.
Back to top
View user's profile Send private message
santhosh1234

New User


Joined: 26 Feb 2008
Posts: 2
Location: Pune

PostPosted: Fri Aug 28, 2009 5:42 pm
Reply with quote

Hi Robert,

Thanks..I should have been careful while posting. Ideally the variable should contain character data after one to one mapping from input file; however if spaces are moved(the corresponding i/p field has spaces), then the XML GENERATE generates the tags with one space..as you have mentioned..I wanted to find out is there any way by giving an option along with the XML GENERATE statement to prevent such tags with no values (spaces) from being displayed.
Back to top
View user's profile Send private message
Sankar S

New User


Joined: 18 Sep 2014
Posts: 1
Location: INDIA

PostPosted: Wed Oct 08, 2014 4:38 pm
Reply with quote

I too need to suppress some of the empty tags in my XML. Is there any way to do it ?
Back to top
View user's profile Send private message
Ed Goodman

Active Member


Joined: 08 Jun 2011
Posts: 556
Location: USA

PostPosted: Fri Oct 10, 2014 1:13 am
Reply with quote

Not built in there isn't. (in before you get hollered at for tailgating an old thread)
Back to top
View user's profile Send private message
babruvahana

New User


Joined: 30 Mar 2008
Posts: 10
Location: hyderabad

PostPosted: Fri Oct 31, 2014 6:08 pm
Reply with quote

You need to write an exit program called by the parser program you need to generate the parserprogram with exit option and in this new program you need to check for fields in your XML TAGS (Key tags) if they are greater than spaces if it is then skip the occurences
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 INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
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 Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Insert trailer for non empty file only DFSORT/ICETOOL 6
Search our Forums:

Back to Top