Highlighted
Absent Member.
Absent Member.
3253 views

Visual COBOL - organization is xml

Jump to solution

[Migrated content. Thread originally posted on 14 February 2011]

Hi,

i'm testing Visual Cobol with Eclipse and want to make an xml file.
When i use organization is xml, eclipse gives me a compilation error.

Documentation is here :

http://community.microfocus.com/library/docs/2_Visual_COBOL_for_Eclipse_Windows/7252_XML_Syntax__SELECT_Clause

Best regards,

Renzo
0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Visual COBOL - organization is xml

Jump to solution
XML GENERATE General Rule 8 states:
If a character value consists only of spaces, one space remains as the value after trimming is finished.

In order to remove the blank tags you can use an Occurs Depending On to limit the scope of the data items used.
The following will contain only the 3 tags that you want:


       working-storage section.
       01 XML-DATA.
          03 XML-DATA-REC.
             05 XML-DATA-DETAIL OCCURS 1 to 100 depending on ws-count.
                07 XML-NUMBER PIC X(04).
                07 XML-STRING PIC X(40).
       01 ws-count            pic 9(3)   value 3.
       01 ws-xml-count        pic 9(9).
       01 ws-xml-data         pic x(5000) value spaces.

       procedure division.
          move "TST1" to xml-number(1)
          move "TEST-STRING1" to xml-string(1)
          move "TST2" to xml-number(2)
          move "TEST-STRING2" to xml-string(2)
          move "TST3" to xml-number(3)
          move "TEST-STRING3" to xml-string(3)
          move 3 to ws-count

          XML GENERATE WS-XML-DATA FROM XML-DATA
              COUNT IN WS-XML-COUNT
              WITH XML-DECLARATION

         

View solution in original post

0 Likes
7 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Visual COBOL - organization is xml

Jump to solution
This seems to be a case where the documentation is ahead of the technology release.
The XML preprocessor technology is not in the current Visual COBOL R3 release.

It is slated for release in R4.

The R3 release does support the XML GENERATE and XML PARSE statements.
See: XML GENERATE
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Visual COBOL - organization is xml

Jump to solution

XML GENERATE gives me xml, but is not flexibel.

I have the following in WORKING STORAGE :

01 XML-DATA.
03 XML-DATA-REC.
05 XML-DATA-DETAIL OCCURS 100.
07 XML-NUMBER PIC X(04).
07 XML-STRING PIC X(40).

When i only fill 3 rows in my table, and i use the following statement :

XML GENERATE WS-XML-DATA FROM XML-DATA
COUNT IN WS-XML-COUNT
WITH XML-DECLARATION

I get the following result :

<?xml version="1.0" ?><XML-DATA><XML-DATA-REC><XML-DATA-DETAIL><XML-NUMBER>0001</XML-NUMBER><XML-STRING>TEST1</XML-STRING></XML-DATA-DETAIL><XML-DATA-DETAIL><XML-NUMBER>0002</XML-NUMBER><XML-STRING>TEST2</XML-STRING></XML-DATA-DETAIL><XML-DATA-DETAIL><XML-NUMBER>0003</XML-NUMBER><XML-STRING>TEST3</XML-STRING></XML-DATA-DETAIL><XML-DATA-DETAIL><XML-NUMBER> </XML-NUMBER><XML-STRING> </XML-STRING></XML-DATA-DETAIL><XML-DATA-DETAIL><XML-NUMBER> </XML-NUMBER><XML-STRING> </XML-STRING></XML-DATA-DETAIL>

...

<XML-DATA-DETAIL><XML-NUMBER> </XML-NUMBER><XML-STRING> </XML-STRING></XML-DATA-DETAIL><XML-DATA-DETAIL><XML-NUMBER> </XML-NUMBER><XML-STRING> </XML-STRING></XML-DATA-DETAIL><XML-DATA-DETAIL><XML-NUMBER> </XML-NUMBER><XML-STRING> </XML-STRING></XML-DATA-DETAIL><XML-DATA-DETAIL><XML-NUMBER> </XML-NUMBER><XML-STRING> </XML-STRING></XML-DATA-DETAIL></XML-DATA-REC></XML-DATA>

Can i generate xml without the empty fields from the table ?

Regards,

Renzo

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Visual COBOL - organization is xml

Jump to solution
XML GENERATE General Rule 8 states:
If a character value consists only of spaces, one space remains as the value after trimming is finished.

In order to remove the blank tags you can use an Occurs Depending On to limit the scope of the data items used.
The following will contain only the 3 tags that you want:


       working-storage section.
       01 XML-DATA.
          03 XML-DATA-REC.
             05 XML-DATA-DETAIL OCCURS 1 to 100 depending on ws-count.
                07 XML-NUMBER PIC X(04).
                07 XML-STRING PIC X(40).
       01 ws-count            pic 9(3)   value 3.
       01 ws-xml-count        pic 9(9).
       01 ws-xml-data         pic x(5000) value spaces.

       procedure division.
          move "TST1" to xml-number(1)
          move "TEST-STRING1" to xml-string(1)
          move "TST2" to xml-number(2)
          move "TEST-STRING2" to xml-string(2)
          move "TST3" to xml-number(3)
          move "TEST-STRING3" to xml-string(3)
          move 3 to ws-count

          XML GENERATE WS-XML-DATA FROM XML-DATA
              COUNT IN WS-XML-COUNT
              WITH XML-DECLARATION

         

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Visual COBOL - organization is xml

Jump to solution
Problem solved.

Thanks,

Renzo
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Visual COBOL - organization is xml

Jump to solution

Hi Chiris,

what is the relation between XML-DATA and WS-XML-DATA? How can we define the size any formula?

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Visual COBOL - organization is xml

Jump to solution

Hi Chris,

I do have one more query on where I can declare multiple array structure like two dimensional in same XML format.

Please advise.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Visual COBOL - organization is xml

Jump to solution

Hi Partha,

In the example in this thread WS-XML-DATA will be the target field that will receive the generated XML upon completion. The field names under XML-DATA will be used as the tag names within the XML and the actual elementary fields like XML-NUMBER and XML-STRING will contain the data.

The best answer is to copy and paste this code into a Visual COBOL project and run it and see what is generated.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.