COBOL and XML Schema mapping

Utility programs DFHLS2WS and DFHWS2LS support mappings between COBOL data structures and the XML Schema definitions that are included in each Web service description.

COBOL to XML Schema

COBOL names are converted to XML names according to the following rules:Start of change
  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. Hyphens are replaced by underscore characters. Strings of contiguous hyphens are replaced by contiguous underscores.

    For example, current-user--id becomes current_user__id.

  3. Segments of names that are delimited by hyphens and that contain only upper case characters are converted to lower case.

    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.

End of change
DFHLS2WS maps COBOL data description elements to schema elements according to the following table. COBOL data description elements that are not shown in the table are not supported by DFHLS2WS. The following restrictions also apply:
  • Start of changeData description items with level-numbers of 66 and 77 are not supported. Data description items with a level-number of 88 are ignored.End of change
  • 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
  • Start of changeThe SIGN clause SIGN TRAILING is supported. The SIGN clause SIGN LEADING is only supported when the mapping level specified in DFHLS2WS is 1.2.End of change
  • Start of changeSEPARATE CHARACTER is supported at a mapping level of 1.2 for both SIGN TRAILING and SIGN LEADING clauses.End of change
  • Start of changeThe following phrases on the USAGE clause are not supported:
    • OBJECT REFERENCE
    • POINTER
    • FUNCTION-POINTER
    • PROCEDURE-POINTER
    End of change
  • Start of changeThe following phrases on the USAGE clause are supported at a mapping level of 1.2.
    • COMPUTATIONAL-1
    • COMPUTATIONAL-2
    End of change
  • The only PICTURE characters supported for DISPLAY and COMPUTATIONAL-5 data description items are 9 and S.
  • The PICTURE characters supported for PACKED-DECIMAL data description items are 9, S, and V.
  • Start of changeIf the MAPPING-LEVEL parameter is set to 1.2 and the CHAR-VARYING parameter is set to NULL, character arrays are mapped to an xsd:string and are processed as null terminated strings.End of change
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="n"/>
    <xsd:whiteSpace value="preserve"/>
  </xsd:restriction>
</xsd:simpleType>

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.
Start of change

PIC S9(n) COMP
PIC S9(n) COMP-4
PIC S9(n) COMP-5
PIC S9(n) BINARY

End of change where n ≤ 4.
<xsd:simpleType>
  <xsd:restriction base="xsd:short">
  </xsd:restriction>
</xsd:simpleType>
Start of change

PIC S9(n) COMP
PIC S9(n) COMP-4
PIC S9(n) COMP-5
PIC S9(n) BINARY

End of change where 5 ≤ n ≤ 9.
<xsd:simpleType>
  <xsd:restriction base="xsd:int">
  </xsd:restriction>
</xsd:simpleType>
Start of change

PIC S9(n) COMP
PIC S9(n) COMP-4
PIC S9(n) COMP-5
PIC S9(n) BINARY

End of change where 9 <n.
<xsd:simpleType>
  <xsd:restriction base="xsd:long">
  </xsd:restriction>
</xsd:simpleType>
Start of change

PIC 9(n) COMP
PIC 9(n) COMP-4
PIC 9(n) COMP-5
PIC 9(n) BINARY

End of change where n ≤ 4.
<xsd:simpleType>
  <xsd:restriction base="xsd:unsignedShort">
  </xsd:restriction>
</xsd:simpleType>
Start of change

PIC 9(n) COMP
PIC 9(n) COMP-4
PIC 9(n) COMP-5
PIC 9(n) BINARY

End of change where 5 ≤ n ≤ 9.
<xsd:simpleType>
  <xsd:restriction base="xsd:unsignedInt">
  </xsd:restriction>
</xsd:simpleType>
Start of change

PIC 9(n) COMP
PIC 9(n) COMP-4
PIC 9(n) COMP-5
PIC 9(n) BINARY

End of change 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.
Start of changePIC S9(m)V9(n) DISPLAY

Supported at mapping level 1.2 only

End of change
Start of change
<xsd:simpleType>
  <xsd:restriction base="xsd:decimal">
    <xsd:totalDigits value="p"/>
    <xsd:fractionDigits value="n"/>
  </xsd:restriction>
</xsd:simpleType>
where p = m + n.End of change
Start of changeCOMP-1

Supported at mapping level 1.2 only

End of change
Start of change
<xsd:simpleType>
  <xsd:restriction base="xsd:float">
  </xsd:restriction>
</xsd:simpletype>
End of change
Start of changeCOMP-2

Supported at mapping level 1.2 only

End of change
Start of change
<xsd:simpleType>
  <xsd:restriction base="xsd:double">
  </xsd:restriction>
</xsd:simpletype>
End of change

XML schema to COBOL

The CICS® Web services assistant generates unique and valid names for COBOL variables from the schema element names using the following rules:
  1. COBOL reserved words are prefixed with 'X'.

    For example, DISPLAY becomes XDISPLAY.

  2. Characters other than A-Z, a-z, 0-9 or hyphen are replaced with 'X'.

    For example, monthly_total becomes monthlyXtotal.

  3. Start of changeIf the last character is a hyphen, it is replaced with 'X'.

    For example, ca-request- becomes ca-requestX.

    End of change
  4. If the schema specifies that the variable has varying cardinality (that is, minOccurs and maxOccurs are specified with different values), and the schema element name is longer than 23 characters, it is truncated to that length.

    If the schema specifies that the variable has fixed cardinality, and the schema element name is longer than 28 characters, it is truncated to that length.

  5. Start of changeDuplicate names in the same scope are made unique by the addition of one or two numeric digits to the second and subsequent instances of the name.

    For example, three instances of year become year, year1 and year2.

    End of change
  6. Start of changeFive characters are reserved for the strings -cont or -num which are used when the schema specifies that the variable has varying cardinality; that is, when minOccurs and maxOccurs are specified.

    For more information, see Variable arrays of elements.

    End of change
  7. Start of changeFor attributes, the previous rules are applied to the attribute name. The prefix attr- is added to the attribute name, and this is followed by -value or -exist. If the total length is longer than 28 characters, the attribute name is truncated. For more information, see Support for XML attributes.

    The nillable attribute has special rules. The prefix attr- is added, but nil- is also added to the beginning of the attribute name. The attribute name is followed by -value. If the total length is longer than 28 characters, the attribute name is truncated.

    End of change
The total length of the resulting name is 30 characters or less.
DFHWS2LS maps schema types to COBOL data description elements using the specified mapping level according to the following table. You should also note the following points:
Start of change
Schema simple type COBOL data description at mapping levels 1.0 and 1.1 COBOL data description at mapping level 1.2
<xsd:simpleType>
  <xsd:restriction base="xsd:anyType">
  </xsd:restriction>
</xsd:simpleType>

Not supported

Not supported

<xsd:simpleType>
  <xsd:restriction base="xsd:anySimpletype">
  </xsd:restriction>
</xsd:simpleType>

PIC X(255)

Supported at mapping level 1.1

PIC X(255)

<xsd:simpleType>
  <xsd:restriction base="xsd:type">
	   <xsd:length value="z"/>
  </xsd:restriction>
</xsd:simpleType>
where type is one of:
  • string
  • normalizedString
  • token
  • Name
  • NMTOKEN
  • language
  • NCName
  • ID
  • IDREF
  • ENTITY
  • hexBinary

PIC X(z)

PIC X(z)

<xsd:simpleType>
  <xsd:restriction base="xsd:type">
  </xsd:restriction>
</xsd:simpleType>
where type is one of:
  • duration
  • date
  • dateTime
  • time
  • gDay
  • gMonth
  • gYear
  • gMonthDay
  • gYearMonth

PIC X(32)

PIC X(32)

<xsd:simpleType>
  <xsd:restriction base="xsd:type">
  </xsd:restriction>
</xsd:simpleType>
where type is one of:
  • byte
  • unsignedByte

PIC X DISPLAY

PIC X DISPLAY

<xsd:simpleType>
  <xsd:restriction base="xsd:short">
  </xsd:restriction>
</xsd:simpleType>

PIC S9999 COMP-5 SYNC
or
PIC S9999 DISPLAY

PIC S9999 COMP-5 SYNC
or
PIC S9999 DISPLAY

<xsd:simpleType>
  <xsd:restriction base="xsd:unsignedShort">
  </xsd:restriction>
</xsd:simpleType>

PIC 9999 COMP-5 SYNC
or
PIC 9999 DISPLAY

PIC 9999 COMP-5 SYNC
or
PIC 9999 DISPLAY

Start of change
<xsd:simpleType>
  <xsd:restriction base="xsd:integer">
  </xsd:restriction>
</xsd:simpleType>
End of change
Start of change

PIC S9(18) COMP-3

End of change
Start of change

PIC S9(18) COMP-3

End of change
<xsd:simpleType>
  <xsd:restriction base="xsd:int">
  </xsd:restriction>
</xsd:simpleType>

PIC S9(9) COMP-5 SYNC
or
PIC S9(9) DISPLAY

PIC S9(9) COMP-5 SYNC
or
PIC S9(9) DISPLAY

<xsd:simpleType>
  <xsd:restriction base="xsd:unsignedInt">
  </xsd:restriction>
</xsd:simpleType>

PIC 9(9) COMP-5 SYNC
or
PIC 9(9) DISPLAY

PIC 9(9) COMP-5 SYNC
or
PIC 9(9) DISPLAY

<xsd:simpleType>
  <xsd:restriction base="xsd:long">
  </xsd:restriction>
</xsd:simpleType>

PIC S9(18) COMP-5 SYNC
or
PIC S9(18) DISPLAY

PIC S9(18) COMP-5 SYNC
or
PIC S9(18) DISPLAY

<xsd:simpleType>
  <xsd:restriction base="xsd:unsignedLong">
  </xsd:restriction>
</xsd:simpleType>

PIC 9(18) COMP-5 SYNC
or
PIC 9(18) DISPLAY

PIC 9(18) COMP-5 SYNC
or
PIC 9(18) DISPLAY

<xsd:simpleType>
  <xsd:restriction base="xsd:decimal">
    <xsd:totalDigits value="m"
    <xsd:fractionDigits value="n"
  </xsd:restriction>
</xsd:simpleType>

PIC 9(p)V9(n) COMP-3

where p = m - n.

PIC 9(p)V9(n) COMP-3

where p = m - n.
<xsd:simpleType>
  <xsd:restriction base="xsd:boolean">
  </xsd:restriction>
</xsd:simpleType>

PIC X DISPLAY

PIC X DISPLAY

<xsd:simpleType>
	<xsd:list>
     <xsd:simpleType>
         <xsd:restriction base="xsd:int"/>
     </xsd:simpleType>
  </xsd:list>
</xsd:simpleType>

PIC X(255)

Supported at mapping level 1.1

PIC X(255)

<xsd:simpleType> 
	<xsd:union memberTypes="xsd:int xsd:string"/>
</xsd:simpleType>

PIC X(255)

Supported at mapping level 1.1

PIC X(255)

<xsd:simpleType>
	<xsd:restriction base="xsd:base64Binary">
  		<xsd:length value="z"/>
	</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType>
	<xsd:restriction base="xsd:base64Binary">
  	</xsd:restriction>
</xsd:simpleType>
where the length is not defined

PIC X(y)

where y =4×(ceil(z/3)). ceil(x) is the smallest integer greater than or equal to x

Supported at mapping level 1.1

PIC X(z)

where the length is fixed

PIC X(16)

where the length is not defined. The field holds the 16-byte name of the container that stores the binary data.
<xsd:simpleType>
  <xsd:restriction base="xsd:float">
  </xsd:restriction>
</xsd:simpletype>

PIC X(32)

COMP-1

<xsd:simpleType>
  <xsd:restriction base="xsd:double">
  </xsd:restriction>
</xsd:simpletype>

PIC X(32)

COMP-2

End of change
Some of the Schema types shown in the table map to a COBOL format of COMP-5 SYNC or of DISPLAY, depending upon what values (if any) are specified in the <minInclusive> and <maxInclusive> facets: When any other value is specified, or no value is specified, COMP-5 SYNC is used.