Previous Topic: ASN.1 Tags

Next Topic: MDO Tags

Explicit and Implicit Tagging

Each ASN.1 base type has a predefined tag number in the UNIVERSAL tag class. Since all data components must be of a base ASN.1 type a default tag value exists for all data items. However ASN.1 allows these tags to be overridden and data to be explicitly tagged with any tag value. In fact, any data component can be tagged more than once, the tags being applied left to right in the order defined.

For example:

component1  [ APPLICATION 23 ]  [ 3 ]  INTEGER

produces the following tags for component1:

In general, where a data component is explicitly tagged, it is followed by either more explicit tags, or its UNIVERSAL tag for the underlying base type as shown in the example above. However, use of the IMPLICIT keyword before a tag, or before a typeReference, indicates that the next tag is understood (implied), and is not encoded.

For example:

component1 [ APPLICATION 23 ] IMPLICIT INTEGER

produces just one tag: APPLICATION class, tag number 23.

The INTEGER tag is implied and not encoded due to the presence of the IMPLICIT keyword.

Note that following the DEFINITIONS keyword in the module header the tagging defaults can be set for the module. The default is EXPLICIT TAGS indicating all tags are produced unless the IMPLICIT keyword is used to override. The IMPLICIT TAGS options can be used to indicate that only the first tag encountered for a component is used, the rest being implicit (except for the types CHOICE and ANY DEFINED BY, when all tags apply).