View previous topic :: View next topic
|
Author |
Message |
santhosh1234
New User
Joined: 26 Feb 2008 Posts: 2 Location: Pune
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
santhosh1234
New User
Joined: 26 Feb 2008 Posts: 2 Location: Pune
|
|
|
|
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 |
|
|
Sankar S
New User
Joined: 18 Sep 2014 Posts: 1 Location: INDIA
|
|
|
|
I too need to suppress some of the empty tags in my XML. Is there any way to do it ? |
|
Back to top |
|
|
Ed Goodman
Active Member
Joined: 08 Jun 2011 Posts: 556 Location: USA
|
|
|
|
Not built in there isn't. (in before you get hollered at for tailgating an old thread) |
|
Back to top |
|
|
babruvahana
New User
Joined: 30 Mar 2008 Posts: 10 Location: hyderabad
|
|
|
|
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 |
|
|
|