To access the element in a choice construct after decoding, the following two methods can be used (both are defined in the Asn1Choice base class):
getChoiceID – this returns an identifier equal to one the generated choice identifier constants, and
getElement – this returns a reference to the decoded element object. It is of type Asn1Type but it can be upcast to the correct element type using information from the getChoiceID call.
In addition, the compiler generates a getElemName method that can be used to get the textual name of the decoded element.
XSD <xsd:union> Type Mapping
The <xsd:union> type is handled in a similar fashion to a choice type. The main difference is that the items in a union are not tagged. As per X.694, special element names are generated for these items for use in an ASN.1 CHOICE type. These names are based on the base name alt and progress with sequential digits added for each addional union item (alt-1, alt- 2, etc.). XML decoding is accomplished by attempting to decode the content of each alternative in the union and setting the value to the first alternative that can be decoded successfully.