Tagged Type

In ASN.1, it is possible to create new custom types using ASN.1 tag values as identifiers. These identifiers are built into BER or DER encoded messages. In general, these tags have no meaning in an XSD representation of an ASN.1 type that is used to create or validate XML markup. However, if the schema definition is to be used to generate a BER or DER instance of a type, the tag information will be required. For this reason, it is possible to add either non-native attributes or an application information annotation (appinfo) to the generated XSD type describing the ASN.1 tags.

The annotation carries all of the information an application would need to know to encode a BER or DER message of the given type. This includes the tag's class, identifier number, and how it is applied (IMPLICIT or EXPLICIT). The type that specifies this information is the asn1:TagInfo type in the Objective Systems XSD class library.

For the non-native attributes case (specified by adding -attrs tags or -attrs with no qualifiers to the ASN1C command-line), the mapping of an ASN.1 tagged type to XSD is as follows:

ASN.1 production:

   TypeName ::= Tagging [ TagClass TagID ] ASN1Type

Generated XSD code:

   <xsd:complexType name="TypeName" asn1:tag="[TagClass TagID]"
      asn1:tagging="EXPLICIT">
      equivalent XSD type mapping for ASN1Type
   </xsd:complexType>

For the appInfo case (specified by adding -appinfo tags or -appinfo with no qualifiers to the ASN1C command-line), the mapping is as follows:

   <xsd:complexType name="TypeName">
      <xsd:annotation>
         <xsd:appinfo>
            <asn1:TagInfo>
               <asn1:TagClass> TagClass </asn1:TagClass>
               <asn1:TagID> TagID </asn1:TagID>
               <asn1:Tagging> Tagging </asn1:Tagging>
            </asn1:TagInfo>
         </xsd:appinfo>
      </xsd:annotation>
      equivalent XSD type mapping for ASN1Type
   </xsd:complexType>

Tagging in the definition above is optional. If present, it is equal to either the keyword EXPLICIT or IMPLICIT. The default value is EXPLICIT. A default value for all types in a module can also be specified in the ASN.1 module header.

The tag's form (constructed or primitive) is not specified in the mapping above. This is because this can be determined by an application that is encoding or decoding a message of the given type.