Mapping XML Schema structures to PL/I structures

This section describes how XSD structures are mapped to PL/I structures in the WSDL2PLI scenario.

Typically a PL/I major structure (01-level) is generated to contain all of the PL/I minor structures, elementary variables, and arrays that correspond to XML elements and XML attributes in a source XSD. With few exceptions, the hierarchy of the PL/I major and minor structures generated from the XSD will match that of the XSD.

The mappings in the this topic use the following pseudocode function definitions:

  • depth(): This function returns the hierarchical depth of an XSD element or attribute.
  • pli_name(): This function returns a unique PL/I identifier derived from an XSD element or attribute name. Uniqueness is determined using the fully qualified path of the identifier. (See Creation of PL/I identifiers.)

  • pli_type(): This function returns a PL/I data declaration derived from an XSD simple type definition. For user-defined types, derivation is performed using the base built-in or derived simple type. (See Enterprise PL/I structures in the WSDL2PLI scenario.)

Mapping elementary XML elements

An elementary XML element is one that does not contain other elements, although it can have attributes and character content.

  • This mapping shows the simple case:

    Table 1. Elementary XML elements with built-in or derived simple types
    Language: Declaration:
    XSD <xsd:element name=”eleName” type=”simpleTypeName” />
    PL/I depth(xsd:element) pli_name(eleName) pli_type(simpleTypeName)
  • An optional elementary XML element contains "minOccurs=0" and "maxOccurs=1":

    Table 2. Optional elementary XML elements
    Language: Declaration:
    XSD <xsd:element name=”eleName” type=”simpleTypeName” minOccurs=”0” maxOccurs=”1” />
    PL/I
    depth(xsd:element) (pli_name(eleName) + ”_bit1”) BIT(1) ALIGNED,
        depth(xsd:element) pli_name(eleName) pli_type(simpleTypeName)
    1See Suffixes appended to PL/I identifiers.
  • A repeating elementary XML element is mapped to an array:

    Table 3. Repeating elementary XML elements (arrays)
    Language: Declaration:
    XSD <xsd:element name=”eleName” type=”simpleTypeName” minOccurs=”m” maxOccurs=”n” />
    PL/I One of the following:
    • [ depth(xsd:element) (pli_name(eleName) + ”_lim1”) SIGNED FIXED BINARY(31), ]2
    • [ depth(xsd:element) (pli_name(eleName) + ”_cnt1”) SIGNED FIXED BINARY(31), ]3
    • [ depth(xsd:element) pli_name(eleName) (n) pli_type(simpleTypeName), ]4 or
    • [ depth(xsd:element) pli_name(eleName) (_ref._lim1 REFER _lim1) pli_type(simpleTypeName) ]5
    1See  Suffixes appended to PL/I identifiers.
    2Generated when maxOccurs > element_max_occurs_limit or maxOccurs=”unbounded”.
    3Generated when maxOccurs > 1.
    4Generated when maxOccurs <= element_max_occurs_limit.
    5Generated when maxOccurs) > element_max_occurs_limit or maxOccurs=”unbounded”.
  • An elementary XML element can contain characters and attributes:

    Table 4. Elementary XML elements with character and attribute contents
    Language: Declaration:
    XSD
    <xsd:element name=”eleName” type=”complexTypeName” />
    <xsd:complexType name=”complexTypeName”>
        <xsd:simpleContent>
            <xsd:extension base=”simpleTypeName1”>
                <xsd:attribute name=”attName” type=”simpleTypeName2” />
            </xsd:extension>
        </xsd:simpleContent>
    </xsd:complexType>
    PL/I
    depth(xsd:element) pli_name(eleName) ,
        (depth(xsd:element) + 1) pli_name(“text”) pli_type(simpleTypeName1),
        (depth(xsd:element) + 1) (pli_name(attName) + “_bit1”) BIT(1) ALIGNED,
        (depth(xsd:element) + 1) (pli_name(attName) + “_att1”) pli_type(simpleTypeName2)
    1See Suffixes appended to PL/I identifiers.

Mapping composed XML elements

A composed XML elements is one that can contain further elementary or composed XML elements and XML attributes.

  • This mapping shows the simple case:

    Table 5. Composed XML elements with elementary and attribute contents
    Language: Declaration:
    XSD
    <xsd:element name=”eleName1” type=”complexTypeName” />
    <xsd:complexType name=”complexTypeName” mixed=”false”>
        <xsd:sequence or all>
            <xsd:element name=”eleName2” type=”simpleTypeName1” />
        </xsd:sequence or all>
    <xsd:attribute name=”attName1” type=”simpleTypeName2” use=”optional”/>
    </xsd:complexType>
    PL/I
    depth(xsd:element) pli_name(eleName1) ,
        (depth(xsd:element) + 1) pli_name(eleName2) pli_type(simpleTypeName1),
        (depth(xsd:element) + 1) pli_name(attName1 + ”_bit1”)) BIT(1) ALIGNED,
        (depth(xsd:element) + 1) pli_name(attName1 + ”_att1”) pli_type(simpleTypeName2)
    1See Suffixes appended to PL/I identifiers.
  • An optional composed XML element contains "minOccurs=0" and "maxOccurs=1":

    Table 6. Optional composed XML elements
    Language: Declaration:
    XSD
    <xsd:element name=”eleName1” type=”complexTypeName” minOccurs=”0” maxOccurs=”1”/>
    <xsd:complexType name=”complexTypeName” >
        <xsd:sequence or all>
            <xsd:element name=”eleName2” type=”simpleTypeName” />
        </xsd:sequence or all>
    </xsd:complexType>
    PL/I
    depth(xsd:element) pli_name(eleName1 + “_bit1”),
        depth(xsd:element) pli_name(eleName1),
        (depth(xsd:element) + 1) pli_name(eleName2) pli_type(simpleTypeName)
    1See Suffixes appended to PL/I identifiers.
  • A repeating composed XML element is mapped to an array:

    Table 7. Repeating composed XML elements (arrays)
    Language: Declaration:
    XSD
    <xsd:element name=”eleName1” type=”complexTypeName” minOccurs=”m”
    maxOccurs=”n”/>
    <xsd:complexType name=”complexTypeName” mixed=”false”>
        <xsd:sequence or all>
            <xsd:element name=”eleName2” type=”simpleTypeName” minOccurs=”3” maxOccurs=”3” />
        </xsd:sequence or all>
    </xsd:complexType>
    PL/I One of the following:
    • [ depth(xsd:element) pli_name(eleName1 + “_lim1”) SIGNED FIXED BINARY(31), ]2
    • [ depth(xsd:element) pli_name(eleName1 + “_cnt1”) SIGNED FIXED BINARY(31), ]3
    • [ depth(xsd:element) pli_name(eleName1) (n), ]4 or
    • [ depth(xsd:element) pli_name(eleName1) (_ref._lim1 REFER _lim1) ]5
    • depth(xsd:element) pli_name(eleName2) (3) pli_type(simpleTypeName)
    1See  Suffixes appended to PL/I identifiers.
    2Generated when maxOccurs > element_max_occurs_limit or maxOccurs=”unbounded”.
    3Generated when minOccurs != maxOccurs and maxOccurs > 1.
    4Generated when maxOccurs <= element_max_occurs_limit.
    5Generated when maxOccurs > element_max_occurs_limit or maxOccurs=”unbounded”.