Regardless of whether your XML schema was created with named types or anonymous types, PL/I constants can be generated for strings that contain an enumeration facet.
When an XML schema is constructed by using named simple types that include an enumeration facet, the named simple type only needs to be constructed once within the schema. Named types are unique which allows PL/I constants to be generated only once for enumerated strings. After being generated, they can be referenced by elements or attributes as many times as needed without the need to regenerate the constants again, avoiding the issue of duplicate PL/I constants. An example of such a schema is show in Figure 1
<xs:simpleType name="rainbowcolor">
<xs:restriction base="xs:string">
<xs:enumeration value="Violet"/>
<xs:enumeration value="Indigo"/>
<xs:enumeration value="Blue"/>
<xs:enumeration value="Green"/>
<xs:enumeration value="Yellow"/>
<xs:enumeration value="Orange"/>
<xs:enumeration value="Red"/>
</xs:restriction>
</xs:simpleType>
The named simple type rainbowcolor can be referenced numerous times as shown in Figure 2.
<xs:schema xmlns:poc="http://schemas.cs.csg.com/poc"...
<xs:element name="color1" type="poc:rainbowcolor:/>
<xs:element name="color2" type="poc:rainbowcolor:/>
<xs:attribute name="att_color3" type="poc:rainbowcolor:/>
After the XML schema has been defined, the PL/I include file includes the generated PL/I constants for the named data types with enumeration facets. The naming convention used for this type is <name of the type>_typ_enm where typ indicates type and enm indicates enumeration. See Suffixes appended to PL/I identifiers for more information about these and other suffixes. An example of the PL/I include file is shown in Figure 3.
/*********************************************************************
* PL/I constants for enumerated strings declared in named simple type
* "poc:rainbowcolor".
**********************************************************************/
DCL 01 rainbowcolor_typ_enm,
02 Violet CHAR VALUE('E589969385A3'x),
02 Indigo CHAR VALUE('C99584898796'x),
02 Blue CHAR VALUE('C293A485'x),
02 Green CHAR VALUE('C799858595'x),
02 Yellow CHAR VALUE('E885939396A6'x),
02 Orange CHAR VALUE('D69981958785'x),
02 Red CHAR VALUE('D98584'x);
<xs:element name="color1" type="poc1:rainbowcolor:/>
<xs:element name="color2" type="poc2:rainbowcolor:/>
/***************************************************************
* PL/I constants for enumerated strings declared in named simple type
* "poc1:rainbowcolor".
********************************************************************/
DCL 01 rainbowcolor_typ_enm,
02 Violet CHAR VALUE('E589969385A3'x),
02 Red CHAR VALUE('D98584'x);
/*********************************************************************
* PL/I constants for enumerated strings declared in named simple type
* "poc2:rainbowcolor".
********************************************************************/
DCL 01 rainbowcolor_typ_enm1,
02 Violet CHAR VALUE('E589969385A3'x),
02 Red CHAR VALUE('D98584'x);
For anonymous simple types, PL/I constants are generated each time an anonymous instance is referenced in an element or attribute.
<xs:element name="rcolor">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Violet"/>
<xs:enumeration value="Red"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
/*********************************************************************
* PL/I constants for enumerated strings declared in an anonymous simpl
* e type for element "rcolor".
********************************************************************/
DCL 01 rcolor_ele_enm,
02 Violet CHAR VALUE('E589969385A3'x),
02 Red CHAR VALUE('D98584'x);
The naming convention used for this type is <name of the element>_[ele/att]_enm where ele indicates element, att indicates attribute, and enm indicates enumeration. See Suffixes appended to PL/I identifiers for more information about these and other suffixes.