The cb2xml package reads a Cobol-Copybook and converts it to either
- A java Item tree holding all the Cobol Details (Picture, position, length etc).
- An Xml file containing the Cobol Details (Picture, position, length etc).
The cb2xml package is supplied with Mainframe Cobol details. It is possible to support other Cobol dialects (via Java plugins), the JRecord project does this.
cb2xml converts Cobol:
00000601 REC-FACTURE. 00001103 FS1 PIC X.00001603 FS2. 00002105 FS2A PIC 9.05 RFS2B PIC X(8).
00002605 FS2B REDEFINES RFS2B PIC 9(8).
00003103 FS3. 00003605 FS3A PIC 9.00004105 FS3B PIC X(10). 00004603 FS4. 00005105 FS4A PIC 99.00005605 FS4B PIC 99.00006105 FS4C PIC 99.00006603 FS5 PIC X(5). 00007103 FS6 PIC X(20). 00007603 FS7 PIC 9.00008103 FS8 PIC S9(9)V99COMP-3. 00008603 FS9 PIC S9(9)V99COMP-3. 00009103 FS10 PIC 9.00009603 FS11 PIC S9(9)V99COMP-3. 00010103 FS12 PIC S9(9)V99COMP-3. 00010603 FS13 PIC S9(9)V99COMP-3. 00011103 FS14-15 OCCURS 10. 00011605 FS14 PIC 9.00012105 FS15 PIC S9(9)V99COMP-3. 00012605 FS16 PIC S9(9)V99COMP-3. 00013103 FS17 OCCURS10PIC S9(9)V99COMP-3. 00013603 FS18 PIC 9(6). 00014103 FS19 PIC 9.00024103FILLERPIC X.To xml:
copybook filename="FD8.COP.CLEAN">
<itemdisplay-length="428"level="01"name="REC-FACTURE"position="1"storage-length="428">
<itemdisplay-length="1"level="03"name="FS1"picture="X"position="1"storage-length="1"/>
<itemdisplay-length="9"level="03"name="FS2"position="2"storage-length="9">
<itemdisplay-length="1"level="05"name="FS2A"numeric="true"picture="9"position="2"storage-length="1"/>
<itemdisplay-length="8"level="05"name="RFS2B"picture="X(8)"position="3"redefined="true"storage-length="8"/>
<itemdisplay-length="8"level="05"name="FS2B"numeric="true"picture="9(8)"position="3"redefines="RFS2B"storage-length="8"/>
</item>
<itemdisplay-length="11"level="03"name="FS3"position="11"storage-length="11">
<itemdisplay-length="1"level="05"name="FS3A"numeric="true"picture="9"position="11"storage-length="1"/>
<itemdisplay-length="10"level="05"name="FS3B"picture="X(10)"position="12"storage-length="10"/>
</item>
<itemdisplay-length="6"level="03"name="FS4"position="22"storage-length="6">
<itemdisplay-length="2"level="05"name="FS4A"numeric="true"picture="99"position="22"storage-length="2"/>
<itemdisplay-length="2"level="05"name="FS4B"numeric="true"picture="99"position="24"storage-length="2"/>
<itemdisplay-length="2"level="05"name="FS4C"numeric="true"picture="99"position="26"storage-length="2"/>
</item>
<itemdisplay-length="5"level="03"name="FS5"picture="X(5)"position="28"storage-length="5"/>
<itemdisplay-length="20"level="03"name="FS6"picture="X(20)"position="33"storage-length="20"/>
<itemdisplay-length="1"level="03"name="FS7"numeric="true"picture="9"position="53"storage-length="1"/>
<itemdisplay-length="11"level="03"name="FS8"numeric="true"picture="S9(9)V99"position="54"scale="2"signed="true"storage-length="6"usage="computational-3"/>
<itemdisplay-length="11"level="03"name="FS9"numeric="true"picture="S9(9)V99"position="60"scale="2"signed="true"storage-length="6"usage="computational-3"/>
<itemdisplay-length="1"level="03"name="FS10"numeric="true"picture="9"position="66"storage-length="1"/>
<itemdisplay-length="11"level="03"name="FS11"numeric="true"picture="S9(9)V99"position="67"scale="2"signed="true"storage-length="6"usage="computational-3"/>
<itemdisplay-length="11"level="03"name="FS12"numeric="true"picture="S9(9)V99"position="73"scale="2"signed="true"storage-length="6"usage="computational-3"/>
<itemdisplay-length="11"level="03"name="FS13"numeric="true"picture="S9(9)V99"position="79"scale="2"signed="true"storage-length="6"usage="computational-3"/>
<itemdisplay-length="13"level="03"name="FS14-15"occurs="10"position="85"storage-length="13">
<itemdisplay-length="1"level="05"name="FS14"numeric="true"picture="9"position="85"storage-length="1"/>
<itemdisplay-length="11"level="05"name="FS15"numeric="true"picture="S9(9)V99"position="86"scale="2"signed="true"storage-length="6"usage="computational-3"/>
<itemdisplay-length="11"level="05"name="FS16"numeric="true"picture="S9(9)V99"position="92"scale="2"signed="true"storage-length="6"usage="computational-3"/>
</item>
<itemdisplay-length="11"level="03"name="FS17"numeric="true"occurs="10"picture="S9(9)V99"position="215"scale="2"signed="true"storage-length="6"usage="computational-3"/>
<itemdisplay-length="6"level="03"name="FS18"numeric="true"picture="9(6)"position="275"storage-length="6"/>
<itemdisplay-length="1"level="03"name="FS19"numeric="true"picture="9"position="281"storage-length="1"/>
</item>
</copybook>The examples dircectory holds examples of using cb2xml output in a variety of languages
This stackoverflow answer how one person used cb2xml to convert Cobol files to a database
JRecord uses cobol copybooks. The JRecord library supports reading/writing cobol files from java
cobol2j uses an Xml transform to convert cb2xml xml to it own Xml format