SEQUENCE OF / SET OF

The ASN.1 SEQUENCE OF or SET OF type is used to specify a repeating collection of a given element type. This is similar to an array type in a high-level programming language. For all practical purposes, SEQUENCE OF and SET OF are identical. The remainder of this section will refer to the SEQUENCE OF type only. It can be assumed that all of the defined mappings apply to the SET OF type as well.

The way the SEQUENCE OF type is mapped to XSD depends on the type of the referenced element. If the type is one of the following ASN.1 primitive types (or a type reference that references one of these types):

The mapping is to the XSD list type. This is a list of space-separated identifiers. The syntax is as follows:

ASN.1 production:

   TypeName ::= SEQUENCE OF ElementType

Generated XSD code

   <xsd:simpleType name="TypeName">
      <xsd:list itemType="ElementType">
   </xsd:simpleType>

This will be referred to as the simple case from this point forward.

If the element type is any other type than those listed above, the ASN.1 type is mapped to an XSD sequence complex type that contains a single element of the element type. The generated XSD type also contains the maxOccurs (and possibly the minOccurs) facet to specify the array bounds.

The general mapping of an unbounded SEQUENCE OF type (i.e. one with no size constraint) to XSD is as follows:

ASN.1 production:

   TypeName ::= SEQUENCE OF ElementType

Generated XSD code:

   <xsd:complexType name="TypeName">
      <xsd:sequence maxOccurs="unbounded">
         <xsd:element name="ElementType" type="ElementType"/>
      </xsd:sequence>
   </xsd:complexType>

In this definition, the element name is based on the name of the element type. The element type is the equivalent XSD type for the ASN.1 element type.

As of the 2002 version of the ASN.1 standards, it is now possible to include an element identifier name before the element type name in a SEQUENCE OF definition. This makes it possible to control the name of the element used in the generated XSD definition. The mapping for this case is as follows:

ASN.1 production:

   TypeName ::= SEQUENCE OF elementName ElementType

Generated XSD code:

   <xsd:complexType name="TypeName">
      <xsd:sequence maxOccurs="unbounded">
         <xsd:element name="elementName" type="ElementType"/>
      </xsd:sequence>
   </xsd:complexType>