COBOL Structures Mapping Generator (Schemagen) overview

The LegStar Schemagen project automatically maps COBOL Structures to XML Schema complex types.

LegStar Schemagen translates COBOL structures into XML Schema elements. The resulting XML schema is extended with COBOL specific annotations. For instance, a COBOL sentence such as:

  10 REPLY-ITEMSCOUNT        PIC 9(8) COMP-3.        

Is translated into:

     <xs:element name="ReplyItemscount">
       <xs:annotation>
         <xs:appinfo>
         <cb:cobolElement levelNumber='10' cobolName='REPLY-ITEMSCOUNT'
                          type='PACKED_DECIMAL_ITEM' picture='9(8)'
                          usage='PACKED-DECIMAL' byteLength='5'
                          signed='false' totalDigits='8'/>
         </xs:appinfo>
       </xs:annotation>
       <xs:simpleType>
         <xs:restriction base="xs:unsignedInt">
         <xs:minInclusive value='0' fixed='true'/>
         <xs:maxInclusive value='99999999' fixed='true'/>
         </xs:restriction>
       </xs:simpleType>
     </xs:element>

The COBOL annotation language is important because of the impedance mismatch between the XML schema language and the COBOL language. The use of annotations preserves information such as:

  • Numeric types (Packed decimals do not exist in XML schema for instance)
  • Number of digits (COBOL enforces controls on the number of digits while XML schema does not)
  • Size of character strings (Strings have fixed sizes in COBOL)
  • Occurs Depending On COBOL sentences relate an array with another element giving the actual size

See the COBOL binding language XML Schema page for more information on the COBOL binding language used by Schemagen.

For answers to common questions about LegStar Schemagen, see the FAQ.