Integer Types
XSD defines several integer types including integer, byte, unsignedByte, positiveInteger, etc.. Each of these types is mapped to a C type depending on the following factors:
- The name of the type (for example, unsignedByte is mapped to a different type - OSUINT8 - than integer - OSINT32,
- Value range facets (minInclusive, maxInclusive, minExclusive, maxExclusive) that are applied to the type.
By default, an xsd:integer with no constraints results in the generation of an "OSINT32" type which is a standard C signed 32-bit integer type. The general mapping is as follows:
<xsd:simpleType name="TypeName"> <restriction base="xsd:integer"/> </xsd:simpleType> typedef OSINT32 TypeName; class TypeName : public OSRTBaseType { OSINT32 value; ... } ;
Value range facets will alter the C type used to represent a given integer value. The smallest integer type that can hold the constrained value will always be used. For example, the following declaration declares an integer to hold a value between 2 and 10 (inclusive):
<xsd:simpleType name="Int_2_to_10"> <xsd:restriction base="xsd:integer"> <xsd:minInclusive value="2"/> <xsd:maxInclusive value="10"/> </xsd:restriction> </xsd:simpleType>In this case, a byte type (unsigned char) could be used to hold the value because it must be between 2 and 10 (a signed byte could also be used but an unsigned value is always used whenever negative numbers are not required). Other value ranges would cause different integer types to be used that provide the most efficient amount of storage.
The <typemap> declarations can be used to map an integer number type to a string type. This can be done at global or schema level. This mapping configuration can be used to preserve the format of integer numbers after decoding and reencoding.
<typemap> <xsdtype>integer</xsdtype> <ctype>string</ctype> </typemap>
Copyright © Objective Systems 2002-2008 This document may be distributed in any form, electronic or otherwise, provided that it is distributed in its entirety and that the copyright and this notice are included. |
Objective Systems, Inc.55 Dowlin Forge RoadExton, Pennsylvania 19341 http://www.obj-sys.com Phone: (484) 875-9841 Toll-free: (877) 307-6855 (US only) Fax: (484) 875-9830 info@obj-sys.com |