4.2 Overview of Syntax Encoding
This section provides an overview of the notation and terminology used to represent the syntactic elements (data elements) defined in this message format specification.
All data elements consist of a series of components. Each of the components is composed of a series of 8-bit groups called octets. In this document, the bits are numbered starting from the low-order bit. That is, the low-order (or least significant) bit is called "bit 0" and the high-order (or most significant) bit is called "bit 7."
Five different components may appear in a data element.
- Identifier octet (identifying particular type of data element)
- Length Code (specifying number of octets that appear following it in a data element)
- Qualifier (supplying additional identifying information)
- Property-List component (a Property-List data element containing Property data elements)
- Data Element Contents (containing actual data of the data element)
These components always appear in this order. Not all components are present in all data elements, but the components that are present maintain this relative order.
4.2.1 Identifier Octets
The identifier octet is a numeric code containing information that identifies a data element. It is always the first component in a data element. The Identifier octet contains a one-bit flag, indicating whether or not the data element contains a Property-List, and a 7-bit unique identifier for the data element. The value of the data element identifier also indicates whether the data element has a Qualifier.
The most significant bit (Bit 7) of the identifier octet is set to 1 if there are properties associated with the data element; it is set to 0 if there are none. This bit is independent of the remaining seven bits in the identifier octet, which are called the identifier, and provide unique identification for data elements. The associated properties are specified in a Property-List component.
The second most significant bit (Bit 6) of the identifier octet (the most significant bit of the identifier itself) signifies whether or not the data element has a Qualifier. If the bit is set to 1, then the data element has a Qualifier; if it is a 0, the data element does not have a Qualifier. The seven bits of the identifier uniquely identify the data element.
Table 2 shows the settings of the high-order bits of the identifier octet and their associated meaning. Figure 4 demonstrates the bit-level structure of the identifier octet. In this figure, bit 7 is indiciated with P to show its special use.
bit 7 6 5 4 3 2 1 0
+---------------+
|P 0 x x x x x x| 0xxxxxx uniquely identifies a
+---------------+ data element without a Qualifier.
+---------------+
|P 1 x x x x x x| 1xxxxxx uniquely identifies a
+---------------+ data element with a Qualifier.
FIG. 4. STRUCTURE OF IDENTIFIER OCTETS
Bit Value Meaning
7 0 The data element does not have properties asso-
ciated.
1 The data element has properties associated.
6 0 The data element does not have a Qualifier.
1 The data element has a Qualifier.
TABLE 2. HIGH-ORDER BITS IN THE IDENTIFIER OCTET
4.2.2 Length code and Qualifier components
The Length Code and the Qualifier are both usually one octet in length. They use an encoding scheme that permits extending the component to the size necessary to represent the length of the data element or the value of the Qualifier component.
The most significant bit of the Length Code or Qualifier components determines whether it is one or several octets in length. When the most significant bit is 0, the component is one octet in length. When the most significant bit is 1, the other seven bits of the first octet encode the number of octets in the rest of the component. The actual value begins in the next octet and is interpreted as an unsigned integer.
A single octet is sufficient for most Length Code and Qualifier components. For those cases where the value of the Length Code or the Qualifier must be greater than 127, extra octets can be added, up to a maximum of 127 octets. Figure 5 shows the encoding scheme, as well as an example of a value less than 127 and one greater than 127.
bit 7 6 5 4 3 2 1 0
+---------------+
|0 x x x x x x x| xxxxxxx is the value.
+---------------+
+---------------+------//-------+
|1 n n n n n n n|y y y y y y y y| nnnnnnn is the
+---------------+------//-------+ number of octets
that contain the
value yyyyyyyy.
+---------------+
|0 0 0 0 1 0 0 1| This is an example with a
+---------------+ value of 9 (decimal).
+---------------+---------------+
|1 0 0 0 0 0 0 1|1 0 0 0 0 0 1 0| This example has a
+---------------+---------------+ value of 130 (decimal).
+---------------+---------------+
|1 0 0 0 0 0 1 0|0 0 0 0 0 0 0 1|
+---------------+---------------+
+---------------+
|0 0 1 0 1 1 0 0| This example has a
+---------------+ value of 300 (decimal).
FIG. 5. ENCODING MECHANISM FOR QUALIFIERS AND LENGTH CODES
In order to comply with this message format specification, CBMSs must be able to determine the value of any length code or qualifier that is expressed in three octets or less. (The 2^16 -1). This message format specification places no limitation on the value of a length code or qualifier generated by a CBMS (except for the absolute limitation inherent in the representation scheme). However, the use of length codes and qualifiers with larger values (particularly values in excess of 2^32 -1) should be avoided unless it is known that the receiving system can handle them.
Both Length Codes and Qualifiers have a special convention for dealing with special situations. Length Codes can specify that a data element has indeterminate length; a Qualifier can specify that a data element is implementation defined. These cases are explained further in the next two sections.
4.2.2.1 Length Codes
The length code component immediately follows the identifier octet. It is present in every data element. The Length Code indicates the number of octets following it in a data element (that is, excluding the identifier octet and the length code itself). Length Codes appear in one of three formats: short, long, and indefinite.
A short Length Code is one octet long. Its most significant bit (Bit 7) is set to 0 and its value is in the range 0 through 127.
A long Length Code is at least two octets long. The first octet always has its most significant bit (Bit 7) set to 1. The other seven bits of this octet contain the number of octets making up the rest of the Length Code, and these octets contain (2^1016 - 1) (that is, 127 octets to represent the value).
An indefinite Length Code is one octet long. Its most significant bit (Bit 7) is set to 1 and its other bits are all 0. (See Figure 6.) An indefinite Length Code may appear only as part of a constructor data element; it may not occur in a primitive data element1. A constructor data element with an indefinite length code has an End-Of-Constructor data element as the last data element in its Data Element Contents. (The length of such a constructor data element is unrestricted, although it must contain at least one data element -- the End-of-Constructor that terminates it -- in its Data Element Contents.)
bit 7 6 5 4 3 2 1 0
+---------------+
|0 x x x x x x x| xxxxxxx is the value of the
+---------------+ length code.
+---------------+------//-------+
|1 n n n n n n n|y y y y y y y y| nnnnnnn is the number
+---------------+------//-------+ of octets that contain
the value of the length
code; these are represented
as yyyyyyy.
+---------------+
|1 0 0 0 0 0 0 0| The "indefinite" length code
+---------------+
FIG. 6. REPRESENTATION OF LENGTH CODES
4.2.2.2 Qualifier
If present,the Qualifier component immediately follows the code component. It is used to provide information essential to the interpretation of the data element contents that is beyond that encoded in the identifier octet or length code. For example, the identifier octet could contain the code for a field, and the Qualifier component would specify what kind of field.
The Qualifier component appears in only a few data elements. In the Bit-String data element, it indicates the number of unused bits in the final octet of the Data Element Contents. In the Field and Property data elements, it indicates which field or property the data element represents. In the Compressed and Encrypted data elements, it indicates which compression or encryption algorithm has been used. In the Message data element, it indicates the type of message.
The length of the Qualifier component depends on the encoding of the Qualifier. (See Figure 7.) A short Qualifier is one octet long. Its most significant bit is 0 and its value is in the range 0 through 127. A long Qualifier is at least two octets in length. The most significant bit is always 1 and the other 7 bits indicate the number of octets in the value of the Qualifier.
+--------+--------+--------+
|10000010|00000001 00001010| Qualifier with value
+--------+--------+--------+ 266 (decimal).
+--------+--------+--------+--------+
|10000011|00000000|00000001 00001010| Vendor-Defined
+--------+--------+--------+--------+ Qualifier with
value 266.
+--------+
|10000000| Undefined value for a Qualifier.
+--------+
FIG. 7. EXAMPLES OF QUALIFIER VALUES
This message format specification allows implementations to define their own values for Qualifiers. A vendor-defined Qualifier is any long Qualifier in which the first octet in the value is 0. The value used to identify this Qualifier is not guaranteed to be unique and the same value may be used by different implementations to define different Qualifiers.
4.2.3 Property-List
A Property is an attribute being associated with, but not essential to the interpretation of, a data element. The properties currently defined by this message format specification are Printing-Name and Comment. A Property-List component of a data element is represented by a Property-List data element that in turn contains Property data elements.
A data element contains at most one Property-List. The most significant bit in the identifier octet of the data element indicates whether a Property-List is present.
4.2.4 Data Element Contents
The Data Element Contents component of a data element is the actual data or information represented by a data element. (The other components provide the information necessary to identify and interpret the Data Element Contents.)
In a primitive data element, the Data Element Contents is a series of octets interpreted according to the identifier octet and any qualifier.
In a constructor data element, the Data Element Contents is a series of data elements. When the Length Code component of a constructor data element is "indefinite," the last data element in the constructor's Data Element Contents is End-of-Constructor.
The length of the Data Element Contents (in octets) is the difference between the value of the Length Code and the sum of the following:
- the length of the Qualifier component (depends on the data element)
- the length of the Property-List component.