In Table 12, the direct mapping of XML data types and OPC UA DataTypes is defined. If there are any restrictions on a lossless, bidirectional mapping, this is described in the Comment column. If this column is empty, there are no restrictions.

Table 12 – Mapping of DataTypes

OPC UA DataType

XML DataType

Comment

String

string

Implementations might limit the maximum String size.

Boolean

boolean

Decimal

decimal

Implementations might limit the maximum Decimal size.

Float

float

Double

double

Duration

duration

In this mapping there might be a loss in precision (XML only requires down to minimum fractional second precision of milliseconds, OPC UA based Duration is a double (representing milliseconds).

DateTime

dateTime

Many implementations will not be able to represent the full range of DateTime values. To maximize interoperability, the following rules apply:

When going from XML to an implementation:

  • If the XML value is <= MinDate then the value is MinDate;
  • If the XML value is >= MaxDate then the value is MaxDate;
  • XML values without a TimezoneOffset are assumed to be in UTC;
  • XML values with a TimezoneOffset are converted to UTC;
  • Fractions of seconds not supported by the implementation are dropped.

When going from an implementation to XML:

  • If the value is MinDate the XML is ‘0001-01-01T00:00:00Z’;
  • If the value is MaxDate the XML is ‘9999-12-31T23:59:59Z’;
  • XML values are always in UTC;
  • Fractions of seconds, if supported by the implementation, are included.

Where:

  • MinDate is the earliest date supported by an implementation;
  • MaxDate is the latest date supported by an implementation;
  • All implementations are required to support seconds.

The value of MinDate is the default value and semantically equivalent to a Null value.

UtcTime

dateTimeTimestamp

See limitations of DateTime

ByteString

base64Binary

XML has two ByteString representations – hexBinary and base64Binary. The mapping of OPC UA ByteString to XML base64Binary is defined in OPC 10000-6. The mapping to XML hexBinary is defined in section 5.4.

Implementations might limit the maximum ByteString size.

Int64

long

Int32

int

Int16

short

SByte

byte

UInt64

unsignedLong

UInt32

unsignedInt

UInt16

unsignedShort

Byte

unsignedByte

NormalizedString

normalizedString

Implementations might limit the maximum String size.

In OPC UA, limitations on the string are only defined in the specification but not explicitly defined by the data structure, so implementations not following the specification may provide invalid values.

LocaleId

language

Both data types are based on strings defined in IETF RFC 5646 and should represent the same format, e.g., “en-US”.

OPC UA allows an empty or null string, which is not allowed in XML.

In OPC UA, limitations on the string are only defined in the specification but not explicitly defined by the data structure, so implementations not following the specification may provide invalid values.

In XML, the schema definition only restricts the allowed values to a certain degree, so implementations not following the specification may provide invalid values.

XML only restricts the allowed values to a certain degree in its schema definition, so potentially values could be invalid.

UriString

anyURI

Implementations might limit the maximum String size.