ASN1C Mapping of ASN.1 Syntax to XML Schema

Please download to get full document.

View again

of 26
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Information Report
Category:

Religion & Spirituality

Published:

Views: 0 | Pages: 26

Extension: PDF | Download: 0

Share
Related documents
Description
ASN1C Mapping of ASN.1 Syntax to XML Schema Objective Systems, Inc., Last Update: July 2005 Table of Contents Abstract... 3 General Conventions... 4 Mapping of Top-Level Constructs... 4 Mapping of ASN.1
Transcript
ASN1C Mapping of ASN.1 Syntax to XML Schema Objective Systems, Inc., Last Update: July 2005 Table of Contents Abstract... 3 General Conventions... 4 Mapping of Top-Level Constructs... 4 Mapping of ASN.1 Types... 4 BOOLEAN... 4 INTEGER... 5 BIT STRING... 6 OCTET STRING... 8 Character String Types... 8 Time String Types... 9 ENUMERATED NULL OBJECT IDENTIFIER RELATIVE-OID REAL SEQUENCE SET SEQUENCE OF / SET OF CHOICE Open Type Tagged Types EXTERNAL and EmbeddedPDV Types Mapping of ASN.1 Information Objects CLASS Information Object and Information Object Set Use of Mappings in Type Definitions References... 26 Abstract An effort is currently underway within the ITU-T to map World-Wide Web Consortium (W3C) XML Schema Definitions Language (XSD) to Abstract Syntax Notation 1 (ASN.1). But a parallel effort to provide a mapping in the other direction from ASN.1 to XSD is on hold. Given the currently popularity of XSD for defining new standards, it would seem reasonable that ASN.1 to XSD conversion would be of interest to the ASN.1 community. This paper presents such a mapping. It uses as a basis the T1 Standard s Committee Draft Standard tml Guidelines for mapping ASN.1 syntax and modules to XML Schemas. 1 General Conventions In this document, sections of ASN.1 syntax and XML Schema definitions are shown in plain text (courier font). Within these sections, symbols shown in italics indicate placeholders for items to be substituted. For example, in the statement TypeName ::= A, TypeName would be replaced with a valid ASN.1 name for a type. This paper covers the conversion of ASN.1 module headers and types. Mapping of Top-Level Constructs An ASN.1 module name is mapped to an XML schema namespace. ASN.1 IMPORT statements are mapped to XSD import statements. The ASN.1 EXPORT statement does not have a corresponding construct in XSD. The general form of the XSD namespace and import statements would be as follows: ?xml version= 1.0 ? xsd:schema xmlns:xsd= http://www.w3.org/2001/xmlschema targetnamespace= url/modulename ! - following line would be added for imported module namespace -- xmlns:importedmodulename= importurl/importedmodulename elementformdefault= qualified xsd:import namespace= importurl/importedmodulename schemalocation= importedmodulename.xsd / In this definition, the items in italics would be replaced with text from the ASN.1 specification being converted or a configuration file. The ModuleName and ImportedModuleName items would come from the ASN.1 specification. The URL and importurl items would be configuration parameters. Mapping of ASN.1 Types Each ASN.1 type is mapped to a corresponding XSD type. The following sections describe the mappings for each of the ASN.1 built-in types. BOOLEAN The ASN.1 BOOLEAN type is mapped to the XSD boolean built-in type. TypeName ::= BOOLEAN xsd:restriction base= xsd:boolean / INTEGER The ASN.1 INTEGER type is converted into one of several XSD built-in types depending on value range constraints on the integer type definition. The default conversion if the INTEGER value contains no constraints is to the XSD integer type: TypeName ::= INTEGER xsd:restriction base= xsd:integer / If the integer has a value range constraint that allows a more restrictive XSD type to be used, then that type will be used. For example, if a range of 0 to 255 (inclusive) is specified, an XSD unsignedbyte would be used because it maps exactly to this range. The following table shows the range values for each of the INTEGER type mappings: Lower Bound Upper Bound XSD Type byte unsignedbyte short unsignedshort integer unsignedint long unsignedlong Ranges beyond long or unsignedlong will cause the integer value to be treated as a big integer. This will map to an xsd:string type. An integer can also be specified to be a big integer using the ASN1C isbiginteger/ configuration file setting. If constraints are present on the INTEGER type that are not exactly equal to the lower and upper bounds specified above, then xsd:mininclusive and xsd:maxinclusive facets will be added to the XSD type mapping. For example, the mapping of I ::= INTEGER (0..10) would be done as follows: 1. The most restrictive type would first be chosen based on the constraints. In this case, xsd:byte would be used because it appears first on the list above. 2. Then the xsd:mininclusive and xsd:maxinclusive facets would be added to further restrict the type. This would result in the following mapping: xsd:simpletype name= I xsd:restriction base= xsd:byte xsd:mininclusive value= 0 xsd:maxinclusive value= 10 BIT STRING There is no built-in XSD type that corresponds to the ASN.1 BIT STRING type. For this reason, a custom type was created in the Objective Systems XSD run-time library (asn1.xsd) to model this type. This type is asn1:bitstring and has the following definition: xsd:simpletype name= bitstring xsd:restriction base= xsd:token xsd:pattern value= [0-1]{0,} / The ASN.1 BIT STRING type is converted into a reference to this custom type as follows: TypeName ::= BIT STRING xsd:restriction base= asn1:bitstring / Sized BIT STRING The ASN.1 BIT STRING type may contain a size constraint. This is converted into minlength and maxlength facets in the generated XSD definition: TypeName ::= BIT STRING (SIZE (lower..upper)) xsd:restriction base= asn1:bitstring xsd:minlength value= lower / xsd:maxlength value= upper / BIT STRING with Named Bits A bit string with named bits is handled differently than a normal bit string. This is because the primary use of named bits it to define a bit map of selected bit items. For this reason, a list of enumerated items is used for the type. This allows the names of the bits to be specified in an XML instance of the type. The type also contains application information in the form of an non-native attribute that allows an application to map the items specified in a list to binary bits in a bitmap. The formal mapping of an ASN.1 BIT STRING with named bits to XSD is as follows: TypeName ::= BIT STRING { b1(n1), b2(n2) } xsd:union membertypes= asn1:bitstring xsd:list xsd:simpletype xsd:restriction base= xsd:token xsd:enumeration value= b1 asn1:bitno= n1 / xsd:enumeration value= b2 asn1:bitno= n2 / ... /xsd:list /xsd:union The previous version of this tool also generates the annotation code for this definition. This can also be generated with current version using the -appinfo option. Generated XSD code with annotation: xsd:annotation xsd:appinfo asn1:namedbitinfo asn1:namedbit name= b1 bitnumber= n1 asn1:namedbit name= b2 bitnumber= n2 ... /asn1:namedbitinfo /xsd:appinfo /xsd:annotation xsd:union membertypes= asn1:bitstring xsd:list xsd:simpletype xsd:restriction base= xsd:token xsd:enumeration value= b1 / xsd:enumeration value= b2 / ... /xsd:list /xsd:union The appinfo section will not be needed if the bits are sequentially numbered starting at zero. An application that uses the mapping would be able to calculate the bit numbers based on their position in the document. Example The following ASN.1 BIT STRING type: ColorSet ::= BIT STRING (blue(1), green(3), red(5)) maps to the following XSD type: xsd:simpletype name= colorset xsd:union membertypes= asn1:bitstring xsd:list xsd:simpletype xsd:restriction base= xsd:token xsd:enumeration value= blue asn1:bitno= 1 / xsd:enumeration value= green asn1:bitno= 3 / xsd:enumeration value= red asn1:bitno= 5 / /xsd:list /xsd:union OCTET STRING The ASN.1 OCTET STRING type is converted into the XSD hexbinary type. TypeName ::= OCTET STRING xsd:restriction base= xsd:hexbinary / Sized OCTET STRING The ASN.1 OCTET STRING type may contain a size constraint. This is converted into minlength and maxlength facets in the generated XSD definition: TypeName ::= OCTET STRING (SIZE (lower..upper)) xsd:restriction base= hexbinary xsd:minlength value= lower / xsd:maxlength value= upper / Character String Types All ASN.1 character string useful types (IA5String, VisibleString, etc.) are mapped to the XSD string type. TypeName ::= ASN1CharStringType in this definition, ASN1CharStringType would be replaced with one of the ASN.1 Character String types such as VisibleString. xsd:restriction base= string / ASN.1 character string types may contain a size constraint. This is converted into minlength and maxlength facets in the generated XSD definition: TypeName ::= ASN1CharStringType (SIZE (lower..upper)) xsd:restriction base= xsd:string xsd:minlength value= lower / xsd:maxlength value= upper / ASN.1 character string types may also contain permitted alphabet or pattern constraints. These are converted into pattern facets in the generated XSD definition: TypeName ::= ASN1CharStringType (FROM (charset)) or TypeName ::= ASN1CharStringType (PATTERN (pattern)) xsd:restriction base= xsd:string xsd:pattern value= pattern / In this case, the permitted alphabet character set (charset) is converted into a corresponding pattern for use in the generated XML schema definition. Time String Types The ASN.1 GeneralizedTime and UTCTime types are mapped to the XSD datetime type. TypeName ::= ASN1TimeStringType in this definition, ASN1TimeStringType would be replaced with either GeneralizedTime or UTCTime. xsd:restriction base= datetime / ENUMERATED The ASN.1 ENUMERATED type is converted into an XSD token type with enumeration items. The enumeration items correspond to the enumerated identifiers in the type. If the enumerated items contain numbers (i.e do not follow the standards sequence), then an appinfo annotation is added to the type to allow an application to map the enumerated identifiers to numbers. If appinfo is not present, then an application can safely assume that the enumerated identifiers are in sequential order starting at zero. TypeName ::= ENUMERATED (id1(val1), id2(val2),...) xsd:restriction base= xsd:token xsd:enumeration name= id1 asn1:value= val1 xsd:enumeration name= id2 asn1:value= val2 The previous version of this tool also generates the annotation code for this definition. This can also be generated with current version using -appinfo option. Generated XSD code with annotation: xsd:annotation xsd:appinfo asn1:enuminfo asn1:enumitem name= id1 value= val1 / asn1:enumitem name= id2 value= val2 / /asn1:enuminfo /xsd:appinfo /xsd:annotation xsd:restriction base= xsd:token xsd:enumeration name= id1 xsd:enumeration name= id2 Example The following ASN.1 enumerated type: Colors ::= ENUMERATED (blue(1), green(3), red(5)) maps to the following XSD type xsd:simpletype name= Colors xsd:restriction base= xsd:token xsd:enumeration name= blue asn1:value= 1 xsd:enumeration name= green asn1:value= 3 xsd:enumeration name= red asn1:value= 5 Note that if the identifiers in the enumerated type did not contain numbers (i.e. if the type was ENUMERATED (blue, green, red) ), then the annotation would not be necessary on the type above. NULL There is no built-in XSD type that corresponds to the ASN.1 NULL type. For this reason, a custom type was created in the Objective Systems XSD run-time library (asn1.xsd) to model this type. This type is asn1:null and has the following definition: complextype name= NULL final= #all / This is a non-extendable empty complex type. OBJECT IDENTIFIER There is no built-in XSD type that corresponds to the ASN.1 OBJECT IDENTIFIER type. For this reason, a custom type was created in the Objective Systems XSD run-time library (asn1.xsd) to model this type. This type is asn1:objectidentifier and has the following definition: xsd:simpletype name= objectidentifier xsd:restriction base= xsd:token xsd:pattern value= [0-2]((\.[1-3]?[0-9])(\.\d+)*)? / The pattern enforces the rule in the X.680 standard that the first arc value of an OID must be between 0 and 2, the second arc must be between 0 and 39, and the remaining arcs can be any number. The ASN.1 OBJECT IDENTIFIER type is converted into a reference to this custom type as follows: TypeName ::= OBJECT IDENTIFIER xsd:restriction base= asn1:objectidentifier / RELATIVE-OID There is no built-in XSD type that corresponds to the ASN.1 RELATIVE-OID type. For this reason, a custom type was created in the Objective Systems XSD run-time library (asn1.xsd) to model this type. This type is asn1:relativeoid and has the following definition: xsd:simpletype name= relativeoid xsd:restriction base= xsd:token xsd:pattern value= \d+(\.\d+)* / This is similar to the OBJECT IDENTIFIER type discussed in the previous section except in this case, the patter in simpler. The arc numbers in a RELATIVE-OID are not restricted in any way, hence the simpler pattern. The ASN.1 RELATIVE-OID type is converted into a reference to this custom type as follows: TypeName ::= RELATIVE-OID xsd:restriction base= asn1:relativeoid / REAL The ASN.1 REAL type is mapped to the XSD double built-in type. TypeName ::= REAL xsd:restriction base= xsd:double / SEQUENCE An ASN.1 SEQUENCE is a constructed type consisting of a series of element definitions that must appear in the specified order. This is very similar to the XSD sequence complex type and is therefore mapped to this type. The basic mapping is as follows: TypeName ::= SEQUENCE { element1-name element1-type, element2-name element2-type,... } xsd:complextype name= typename xsd:sequence xsd:element name= element1-name type= element1-type / xsd:element name= element2-name type= element2-name / OPTIONAL keyword Elements within a sequence can be declared to be optional using the OPTIONAL keyword. This indicates that the element is not required in the encoded message. XSD contains the minoccurs facet that can be used to model this behavior. Setting minoccurs equal to zero is the equivalent to declaring an element to be optional because this indicates the element can appear zero to one times in the definition. For example, the following ASN.1 SEQUENCE type: OptInt ::= SEQUENCE { anint INTEGER OPTIONAL } will cause the following XSD complex type to be generated: xsd:complextype name= OptInt xsd:sequence xsd:element name= anint type= xsd:integer minoccurs= 0 / DEFAULT keyword The DEFAULT keyword allows a default value to be specified for elements within the SEQUENCE. XSD contains a default facet that can be used to map elements with this keyword. For example, the following ASN.1 SEQUENCE type: DfltInt ::= SEQUENCE { anint INTEGER DEFAULT 1 } will cause the following XSD complex type to be generated: xsd:complextype name= DfltInt xsd:sequence xsd:element name= anint type= xsd:integer default= 1 / Note that in XSD, default values can only be specified for simple (primitive) types. ASN.1 allows for the specification of default values on complex (constructed) types as well. If an ASN.1 type is encountered that contains a complex default value, the value is dropped in the conversion to XSD. Extension Elements If the SEQUENCE type is extensible (i.e., contains an ellipses marker ), a special element will be inserted to allow unknown elements to be validated. This special element is as follows: xsd:any namespace= ##other processcontents= lax / This element declaration allows any additional elements from other namespaces to exist in a message instance without causing a validation or decoding error. Note the restriction that the element must be defined in a different namespace. This is necessary because if the element existed in the same namespace as other elements, the content model would be non-deterministic. The reason is because a validation program would not be able to determine if the last element is a sequence was a defined element or an extension element. The extension element is marked with a non-native attribute description. For example: DfltInt ::= SEQUENCE { anint INTEGER,..., extelm BOOLEAN } xsd:complextype name= dfltint xsd:sequence xsd:element name= anint type= xsd:integer / xsd:element name= extelm minoccurs= 0 type= xsd:boolean asn1:description= extension element / xsd:any namespace= ##other processcontents= lax minoccurs= 0 / Note: In the ASN.1 SEQUENCE or SET type, all extension elements are optional, whether marked that way or not. SET An ASN.1 SET is a constructed type consisting of a series of element definitions that can appear in any order. This is similar to the XSD all complex type and is therefore mapped to this type. The basic mapping is as follows: TypeName ::= SET { element1-name element1-type, element2-name element2-type,... } xsd:complextype name= typename xsd:all xsd:element name= element1-name type= element1-type / xsd:element name= element2-name type= element2-name / /xsd:all typedef struct { The rules for mapping elements with optional and default values to XSD that were described in the SEQUENCE section above are also applicable to the SET type. 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): BOOLEAN INTEGER ENUMERATED REAL The mapping is to the XSD list type. This is a list of space-separated identifiers. The syntax is as follows: TypeName ::= SEQUENCE OF ElementType xsd:list itemtype= elementtype 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: TypeName ::= SEQUENCE OF ElementType xsd:complextype name= typename xsd:sequence xsd:element name= elementtype type= elementtype maxoccurs= unbounded / In this definition, the element type name is the name of the ASN.1 element type. The element type in the XSD definition 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: TypeName ::= SEQUENCE OF elementname ElementType xsd:complextype name= typename xsd:sequence xsd:element name= elementname type= elementtype maxoccurs= unbounded / Example The following shows the mapping for a SEQUENCE OF INTEGER. Since INTEGER is one of the simple types listed above, an XSD list type is used: SeqOfInt ::= SEQUENCE OF INTEGER xsd:complextype name= seqofint xsd:list itemtype= xsd:integer The following shows the mapping for a SEQUENCE OF UTF8String. Since UTF8String is not one of the simple types listed above, an XSD sequence type is used: SeqOfUTF8 ::= SEQUENCE OF UTF8String xsd:complextype name= seqofutf8 xsd:sequence xsd:element name= utf8string type= xsd:string maxoccurs= unbounded / Note that the element name is the name of the element type. To change the element name, the ASN.1 form that allows an element name could be used: SeqOfUTF8 ::= SEQUENCE OF mystring UTF8String xsd:complextype name= seqofutf8 xsd:sequence xsd:element name= mystring type= xsd:string maxoccurs= unbounded / Sized SEQUENCE OF / SET OF The SEQUENCE OF type may contain a size constr
Recommended
View more...
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks
SAVE OUR EARTH

We need your sign to support Project to invent "SMART AND CONTROLLABLE REFLECTIVE BALLOONS" to cover the Sun and Save Our Earth.

More details...

Sign Now!

We are very appreciated for your Prompt Action!

x