When a SEQUENCE
or SET
contains other
complex data types, it is said to be nested. Types may be nested to an arbitrary depth in
ASN.1, so the resulting output can be extremely verbose in complex
specifications. Moreover, these nested types can be repeating.
The following sections describe how ASN2TXT handles nested types.
A SEQUENCE
is exactly the same as a SET
to
ASN2TXT; the two types are used interchangeably in the following
sections.
One form of nested data occurs when a SEQUENCE
type contains another, as in the following example:
A ::= SEQUENCE { a INTEGER, b SEQUENCE { aa INTEGER, bb BOOLEAN }, c BIT STRING }
In this case, the following columns would be generated in the output CSV:
a,aa,bb,c
ASN2TXT removes all references to the SEQUENCE
named b
. Instead, the inner data (aa
and bb
) is collapsed into the main data type. It is
as though we have instead provided the following specification:
A ::= SEQUENCE { a INTEGER, aa INTEGER, bb BOOLEAN, b BIT STRING }
While the BER encoding of the two specifications is different, they are functionally equivalent to ASN2TXT.
When a CHOICE
appears in a SEQUENCE
,
each of the elements in the CHOICE
is represented in
the output CSV file, even though only one will be selected in any
given message.
For example, take the following specification:
A ::= SEQUENCE { a INTEGER, b CHOICE { aa INTEGER, bb BOOLEAN }, c BIT STRING }
The resulting columns will appear as though the
CHOICE
were actually a SEQUENCE
:
a,aa,bb,c
The last data type to consider is the SEQUENCE
OF
. This is handled very much like a
SEQUENCE
: the SEQUENCE OF
is ignored
and its contents are represented for the column headers as in the
following example:
A ::= SEQUENCE { a INTEGER, b SEQUENCE OF INTEGER, c BIT STRING }
In this case, the columns will be straightforwardly translated:
a,b,c
It is possible that the repeated data type is not primitive, but rather complex. For example:
A ::= SEQUENCE { a INTEGER, b SEQUENCE OF SEQUENCE { aa INTEGER, bb BOOLEAN }, c BIT STRING }
In this case, the innermost data are represented in the output
CSV files, but the actual SEQUENCE OF
will be
ignored as before:
a,aa,bb,c
The exact same columns would be represented if a
CHOICE
were used instead of a
SEQUENCE
. ASN2TXT will always do its best to
collapse nested data types, drilling down to the innermost data
to collect the column headers.