COBOL to XML schema mapping

The DFHLS2WS utility program supports mappings between COBOL data structures and the XML schema definitions that are included in each Web service description.

COBOL names are converted to XML names according to the following rules:
  1. Duplicate names are made unique by the addition of one or more numeric digits.

    For example, two instances of year become year and year1.

  2. Characters that are not valid in XML element names are replaced either by '_' or 'X'.
    1. Hyphens in the variable names are replaced by underscore.

      For example, emp-age is replaced by emp_age.

    2. Special characters like @,#,$ in variable names are replaced by 'X'.
  3. Segments of names that are delimited by hyphens and that contain only uppercase characters are converted to lowercase.

    For example, CA_REQUEST_ID becomes ca_request_id.

  4. A leading underscore character is added to names that start with a numeric character.

    For example, 9A_REQUEST_ID becomes _9a_request_id.

DFHLS2WS maps COBOL data description elements to schema elements as given in Table 1. COBOL data description elements that are not shown in the table are not supported by DFHLS2WS. The following restrictions also apply:
  • Character array is processed as null terminated string. Ensure that it does not have null characters in between, as it might get truncated.
  • Data description items with level-numbers of 66 and 77 are not supported. Data description items with a level-number of 88 are ignored.
  • The following clauses on data description entries are not supported:
    • OCCURS DEPENDING ON
    • OCCURS INDEXED BY
    • REDEFINES
    • RENAMES (that is level 66)
    • DATE FORMAT
  • The following clauses on data description items are ignored:
    • BLANK WHEN ZERO
    • JUSTIFIED
    • VALUE
  • The following phrases on the USAGE clause are not supported:
    • OBJECT REFERENCE
    • POINTER
    • FUNCTION_POINTER
    • PROCEDURE_POINTER
  • The only PICTURE characters supported for DISPLAY and COMPUTATIONAL_5 data description items are 9, S, and Z.

    The PICTURE characters supported for PACKED_DECIMAL data description items are 9, S, V, and Z.

Table 1. COBOL to XML schema mapping
COBOL data description Schema simpleType
PIC X(n)
PIC A(n)
PIC G(n) DISPLAY_1
PIC N(n)
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxlength value="m"/>
<xsd:whiteSpace value="preserve"/>
</xsd:restriction>
</xsd:simpletype>
where m = n
PIC S9 DISPLAY
PIC S99 DISPLAY
PIC S999 DISPLAY
PIC S9999 DISPLAY
<xsd:simpleType>
<xsd:restriction base="xsd:short">
<xsd:minInclusive value="_n"/>
<xsd:maxInclusive value="n"/>
</xsd:restriction>
</xsd:simpletype>
where n is the maximum value that can be represented by the pattern of '9' characters
PIC S9(z) DISPLAY
where 5 ≤ z ≤ 9  
<xsd:simpleType>
<xsd:restriction base="xsd:int">
<xsd:minInclusive value="_n"/>
<xsd:maxInclusive value="n"/>
</xsd:restriction>
</xsd:simpletype>
where n is the maximum value that can be represented by the pattern of '9' characters
PIC S9(z) DISPLAY
where 9 < z  
<xsd:simpleType>
<xsd:restriction base="xsd:long">
<xsd:minInclusive value="_n"/>
<xsd:maxInclusive value="n"/>
</xsd:restriction>
</xsd:simpletype>
where n is the maximum value that can be represented by the pattern of '9' characters
PIC 9 DISPLAY
PIC 99 DISPLAY
PIC 999 DISPLAY
PIC 9999 DISPLAY
<xsd:simpleType>
<xsd:restriction base="xsd:unsignedShort">
<xsd:minInclusive value="0"/>
<xsd:maxInclusive value="n"/>
</xsd:restriction>
</xsd:simpletype>
where n is the maximum value that can be represented by the pattern of '9' characters
PIC 9(z) DISPLAY
where 5 ≤ z ≤ 9  
<xsd:simpleType>
<xsd:restriction base="xsd:unsignedInt">
<xsd:minInclusive value="0"/>
<xsd:maxInclusive value="n"/>
</xsd:restriction>
</xsd:simpletype>
where n is the maximum value that can be represented by the pattern of '9' characters
PIC 9(z) DISPLAY
where 9 < z  
<xsd:simpleType>
<xsd:restriction base="xsd:unsignedLong">
<xsd:minInclusive value="0"/>
<xsd:maxInclusive value="n"/>
</xsd:restriction>
</xsd:simpletype>
where n is the maximum value that can be represented by the pattern of '9' characters
PIC S9(n) COMP
PIC S9(n) COMP_4
PIC S9(n) COMP_5
PIC S9(n) BINARY
where n ≤ 4
<xsd:simpleType>
<xsd:restriction base="xsd:short">
</xsd:restriction>
</xsd:simpletype>
PIC S9(n) COMP
PIC S9(n) COMP_4
PIC S9(n) COMP_5
PIC S9(n) BINARY
where 5 ≤ n ≤ 9
<xsd:simpleType>
<xsd:restriction base="xsd:int">
</xsd:restriction>
</xsd:simpletype>
PIC S9(n) COMP
PIC S9(n) COMP_4
PIC S9(n) COMP_5
PIC S9(n) BINARY
where 9 < n
<xsd:simpleType>
<xsd:restriction base="xsd:long">
</xsd:restriction>
</xsd:simpletype>
PIC 9(n) COMP
PIC 9(n) COMP_4
PIC 9(n) COMP_5
PIC 9(n) BINARY
where n ≤ 4
<xsd:simpleType>
<xsd:restriction base="xsd:unsignedShort">
</xsd:restriction>
</xsd:simpletype>
PIC 9(n) COMP
PIC 9(n) COMP_4
PIC 9(n) COMP_5
PIC 9(n) BINARY
where 5 ≤ n ≤ 9
<xsd:simpleType>
<xsd:restriction base="xsd:unsignedInt">
</xsd:restriction>
</xsd:simpletype>
PIC 9(n) COMP
PIC 9(n) COMP_4
PIC 9(n) COMP_5
PIC 9(n) BINARY
where 9 < n
<xsd:simpleType>
<xsd:restriction base="xsd:unsignedLong">
</xsd:restriction>
</xsd:simpletype>
PIC S9(m)V9(n) COMP_3  
<xsd:simpleType>
<xsd:restriction base="xsd:decimal">
<xsd:totalDigits value="p"/>
<xsd:fractionDigits value="n"/>
</xsd:restriction>
</xsd:simpletype>
where p = m + n
PIC 9(m)V9(n) COMP_3  
<xsd:simpleType>
<xsd:restriction base="xsd:decimal">
<xsd:totalDigits value="p"/>
<xsd:fractionDigits value="n"/>
<xsd:minInclusive value="0"/>
</xsd:restriction>
</xsd:simpletype>
where p = m + n
PIC S9(m)V9(n) DISPLAY
<xsd:simpleType>
<xsd:restriction base="xsd:decimal">
<xsd:totalDigits value="p"/>
<xsd:fractionDigits value="n"/>
</xsd:restriction>
</xsd:simpletype>
where p = m + n
COMP_1
<xsd:simpleType>
<xsd:restriction base="xsd:float">
</xsd:restriction>
</xsd:simpletype>
COMP_2
<xsd:simpleType>
<xsd:restriction base="xsd:double">
</xsd:restriction>
</xsd:simpletype>