XML encoding rules

The APDU are defined according to this simplified ASN1 similar document. The protocol-elements are specified as structured types (SEQUENCE, CHOICE, SEQUENCEOF, SEQUENCEOFCHOICE) and simple-types.

The xml-encoding is done according to the following rules:

  1. The encoding starts at the the top-level declaration _COSEMpdu which defines the CHOICE of all possible protocol-elements.
  2. A CHOICE is encoded as an xml-element having the name of the choice member:

    <GetRequest>
      <GetRequestNormal>
        ...
      </GetRequestNormal>
    </GetRequest>

  3. A SEQUENCE is encoded as an xml-element containing as many xml-elements as sequence members and whose names are the corresponding member-names. A member marked as OPTIONAL may be omitted:

    <AttributeDescriptor>
      <ClassId Value="0008" />
      <InstanceId Value="0000010000FF" />
      <AttributeId Value="02" />
    </AttributeDescriptor>

  4. A SEQUENCEOF is encoded as an xml-element, with a Qty attribute that specifies the number of items. The items are encoded as xml-elements whose names are the type name of the item:

    <AttributeDescriptorList Qty="02">
      <_AttributeDescriptorWithSelection>
        ...
      </_AttributeDescriptorWithSelection>
      <AttributeDescriptorWithSelection>
        ...
      </AttributeDescriptorWithSelection>
    <AttributeDescriptorList>

  5. A SEQUENCEOFCHOICE is encoded as an xml-element with a Qty attribute that specifies the number of items. Each item is encoded as an xml-element whose name is the member name of the CHOICE:

    <ReadRequest Qty="02">
      <VariableName Value="C008" />
      <ParameterisedAccess>
        ...
      </ParameterizedAccess>
    </ReadRequest>

  6. An ENUMERATED is encoded as an (empty) xml-element with a Value attribute:

    <DataAccessError Value="ObjectUnavailable" />


  7. All other types are simple types. They are encoded as (empty) xml-elements with a Value attribute encoded as a string of 2 hex-characters per octet:

    <DoubleLong Value="01020304" />