Overview

X.693 specifies XER ("XML Encoding Rules"). There are three variants of XER given: BASIC-XER (often just XER for short), canonical XER, and EXTENDED-XER. Into this mix, Objective Systems has added its own encoding rules which we'll call OSys-XER. OSys-XER is very similar to XER, but has a few variations that are meant to produce XML documents more closely aligned with what you might get if you were using XML Schema to specify your abstract syntax. Generally, OSys-XER produces fewer tags. The differences between these two sets of encoding rules are discussed in more detail below.

ASN1C supports BASIC-XER, canonical XER, and OSys-XER. It has for some time supported EXTENDED-XER via direct compilation of XSD. In version 6.5.0, we have begun to add direct support for EXTENDED-XER by adding support for some of the XER encoding instructions. Nonetheless, EXTENDED-XER is most fully support today via direct compilation of XSD. By compiling XSD, you can obtain behavior much the same as with OSys-XER, and more.

ASN1C has two runtimes for XML:

Because these two runtimes are so similar, they are discussed in this chapter together. As you read this chapter, it is important to keep in mind when each of these runtimes is used so that you know which cases apply to you.

Note that you may use the -xsd switch when generating XML encoders and decoders. The XML schema produced from the ASN.1 specification using the -xsd switch can be used to validate the XML messages generated using the XML encode functions. Similarly, an XML instance can be validated using the generated XML schema prior to decoding.

Compiler Invocation What is Generated
-xer flag is used to compile ASN.1 without XER encoding instructions

Generated code supports BASIC-XER and canonical XER

-xsd produces schema that validates BASIC-XER encodings.

-xer or -xml flag is used to comple ASN.1 with supported XER encoding instructions (if any instructions are not supported, all instructions are ignored, and the above entry in this table applies)

Generated code supports EXTENDED-XER only.

-xsd produces schema that validates EXTENDED-XER encodings. As of this writing, this is not fully supported.

-xml used to compile ASN.1

Generated code suppports OSys-XER encodings.

-xsd produces schema that validates OSys-XER encodings.

-xml used to compile XSD Generated code supports EXTENDED-XER only.