Support for <xsd:choice>
An <xsd:choice>
element indicates that only
one of the options in the element can be used. The CICS® assistants provide varying degrees
of support for <xsd:choice>
elements at the various mapping
levels.
Support for <xsd:choice>
at mapping level
2.2 and higher
At mapping level 2.2 and higher, DFHWS2LS and DFHSC2LS
provide improved support for <xsd:choice>
elements. The
assistants generate a new container that stores the value associated with
the <xsd:choice>
element. The assistants generate language
structures containing the name of a new container and an extra field:- fieldname-enum
- The discriminating field to indicate which of the options the
<xsd:choice>
element will use. - fieldname-cont
- The name of the container that stores the option to be used. A further language structure is generated to map the value of the option.
<xsd:choice>
element:<xsd:element name="choiceExample">
<xsd:complexType>
<xsd:choice>
<xsd:element name="option1" type="xsd:string" />
<xsd:element name="option2" type="xsd:int" />
<xsd:element name="option3" type="xsd:short" maxOccurs="2" minOccurs="2" />
</xsd:choice>
</xsd:complexType>
</xsd:element>
If this XML schema fragment is processed at mapping
level 2.2 or higher, the assistant generates the following COBOL language
structures: 03 choiceExample.
06 choiceExample-enum PIC X DISPLAY.
88 empty VALUE X'00'.
88 option1 VALUE X'01'.
88 option2 VALUE X'02'.
88 option3 VALUE X'03'.
06 choiceExample-cont PIC X(16).
01 Example-option1.
03 option1-length PIC S9999 COMP-5 SYNC.
03 option1 PIC X(255).
01 Example-option2.
03 option2 PIC S9(9) COMP-5 SYNC.
01 Example-option3.
03 option3 OCCURS 2 PIC S9999 COMP-5 SYNC.
Limitations for <xsd:choice> at mapping level 2.2 and higher
<xsd:choice>
elements;
for example, the following XML is not supported:<xsd:choice>
<xsd:element name ="name1" type="string"/>
<xsd:choice>
<xsd:element name ="name2a" type="string"/>
<xsd:element name ="name2b" type="string"/>
</xsd:choice>
</xsd:choice>
<xsd:choice>
elements;
for example, the following XML is not supported:<xsd:choice maxOccurs="2">
<xsd:element name ="name1" type="string"/>
</xsd:choice>
DFHSC2LS and DFHWS2LS support a maximum
of 255 options in an <xsd:choice>
element.
Support for <xsd:choice>
at mapping level
2.1 and below
At mapping level 2.1 and below, DFHWS2LS provides
limited support for <xsd:choice>
elements. DFHWS2LS treats
each of the options in an <xsd:choice>
element as though
it is an <xsd:sequence>
element that can occur at most
once.
Only one of the options in an <xsd:choice>
element
can be used, so take care when you implement an application using the <xsd:choice>
element
that you generate only valid combinations of options. Each of the elements
has its own count
field in the generated languages structure,
exactly one of which must be set to 1 and the others must all be set to 0.
Any other combination of values is incorrect, except when the <xsd:choice>
is
itself optional, in which case it is valid for all of the fields to be set
to 0.