Previous Topic: Constraints

Next Topic: External Form—Input and Output

CHOICE Type

The CHOICE type allows the definition of a number of components, each of which is an alternative in the data structure. A CHOICE component can be named, such as the details component in this example:

Person ::= SET {
   name       GraphicString,
   birthDate  GeneralString, -- YY/MM/DD
   age        INTEGER,
   details    CHOICE {
              femaleInfo   [1]   FemaleInfo,
              maleInfo     [2]   MaleInfo } }

The details component can contain either femaleInfo or maleInfo, but not both. In this case the details component containing the choice can be referenced directly without first knowing which choice was made. If this is changed to the following:

Person ::= SET {
   name       GraphicString,
   birthDate  GeneralString, -- YY/MM/DD
   age        INTEGER,
   CHOICE {
           femaleInfo   [1] FemaleInfo,
           maleInfo     [2] MaleInfo } }

then both femaleInfo and maleInfo are alternatives within the SET type, and must have unique names within that set. In this case, the actual choice that is present can only be discovered by attempting to reference each possible one, and determining whether it exists or not.

All alternatives of a CHOICE must have unique tags so that they can be differentiated. It is good practice to use explicit tags for each CHOICE item.