You can describe user data types with Extensible Markup Language (XML) notation. Connext DDS provides DTD and XSD files that describe the XML format; see <NDDSHOME>/resource/app/app_support/rtiddsgen/schema/rti_dds_topic_types.dtd and <NDDSHOME>/resource/app/app_support/rtiddsgen/schema/rti_dds_topic_types.xsd, respectively. (<NDDSHOME> is described in Paths Mentioned in Documentation.)
The XML validation performed by RTI Code Generator always uses the DTD definition. If the <!DOCTYPE> tag is not in the XML file, RTI Code Generator will look for the default DTD document in <NDDSHOME>/resource/schema. Otherwise, it will use the location specified in <!DOCTYPE>.
We recommend including a reference to the XSD/DTD files in the XML documents. This provides helpful features in code editors such as Visual Studio® and Eclipse™, including validation and auto-completion while you are editing the XML. We recommend including the reference to the XSD document in the XML files because it provides stricter validation and better auto-completion than the DTD document.
To include a reference to the XSD document in your XML file, use the attribute
xsi:noNamespaceSchemaLocation in the <types> tag. For example :
<?xml version="1.0" encoding="UTF-8"?> <types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "<NDDSHOME>/resource/app/app_support/rtiddsgen/schema/rti_dds_topic_types.xsd"> ... </types>
To include a reference to the DTD document in your XML file, use the <!DOCTYPE> tag. For example:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE types SYSTEM "<NDDSHOME>/resource/app/app_support/rtiddsgen/schema/rti_dds_topic_types.dtd"> <types> ... </types>
Table 3.12 Mapping Type System Constructs to XML shows how to map the type system constructs into XML. For information on the annotations in the table, see 3.3.9 Using Builtin Annotations.
Type/Construct |
Example |
||
IDL |
XML |
IDL |
XML |
char |
char8 |
char char_member; |
<member name="char_member" |
wchar |
char32 |
wchar wchar_member; |
<member name="wchar_member" |
octet |
byte |
octet octet_member; |
<member name="octet_member" |
short |
int16 |
short short_member; |
<member name="short_member" |
unsigned short |
uint16 |
unsigned short |
<member name="unsigned_short_member" |
long |
int32 |
long long_member; |
<member name="long_member"type="int32"/> |
unsigned long |
uint32 |
unsigned long |
<member name= "unsigned_long_member" |
long long |
int64 |
long long |
<member name="long_long_member" |
unsigned long long |
uint64 |
unsigned long long |
<member name="unsigned_long_long_member" |
float |
float32 |
float float_member; |
<member name="float_member" |
double |
float64 |
double double_member; |
<member name="double_member" |
long double |
float128 |
long double |
<member name= "long_double_member" |
boolean |
boolean |
struct PrimitiveStruct { |
<struct name="PrimitiveStruct"> |
unbounded string |
string without stringMaxLength attribute or with stringMaxLength set to -1 |
struct PrimitiveStruct { |
<struct name="PrimitiveStruct"> or <struct name="PrimitiveStruct"> |
bounded string |
string with stringMaxLength attribute |
struct PrimitiveStruct { |
<struct name="PrimitiveStruct"> |
unbounded wstring |
wstring without stringMaxLength attribute or with stringMaxLength set to -1 |
struct PrimitiveStruct { |
<struct name="PrimitiveStruct"> or <struct name="PrimitiveStruct"> |
bounded wstring |
wstring with stringMaxLength attribute |
struct PrimitiveStruct { |
<struct name="PrimitiveStruct"> |
enum |
enum tag |
enum PrimitiveEnum { |
<enum name="PrimitiveEnum"> |
enum PrimitiveEnum { ENUM1=10, ENUM2=20, ENUM3 } enum PrimitiveEnum { @value (10) ENUM1, @value (20) ENUM2, @value (30) ENUM3 } |
<enum name="PrimitiveEnum"> |
||
constant |
const tag |
const double PI = 3.1415; |
<const name="PI" type="double" |
struct |
struct tag |
struct PrimitiveStruct { |
<struct name="PrimitiveStruct"> |
union |
union tag |
union PrimitiveUnion switch |
<union name="PrimitiveUnion"> |
valuetype |
valuetype tag |
valuetype BaseValueType { |
<valuetype name="BaseValueType"> |
typedef |
typedef tag |
typedef short ShortType; |
<typedef name="ShortType" type="short"/> |
struct PrimitiveStruct { typedef PrimitiveStruct |
<struct name="PrimitiveStruct"> |
||
arrays |
Attribute |
struct OneArrayStruct { |
<struct name="OneArrayStruct"> |
struct TwoArrayStruct { |
<struct name="TwoArrayStruct"> |
||
bounded sequence |
Attribute sequenceMaxLength > 0 |
struct SequenceStruct { |
<struct name="SequenceStruct"> |
unbounded sequence |
Attribute sequenceMaxLength set to -1 |
struct SequenceStruct { |
<struct name="SequenceStruct"> |
array of sequences |
Attributes sequenceMaxLength and arrayDimensions |
struct |
<struct name= "ArrayOfSequenceStruct"> |
sequence of arrays |
Must be implemented with a typedef tag |
typedef short struct |
<typedef name="ShortArray" |
sequence of sequences |
Must be implemented with a typedef tag |
typedef sequence<short,4> struct |
<typedef name="ShortSequence" type="short"sequenceMaxLength="4"/> <struct name="SequenceofSequencesStruct"> |
module |
module tag |
module PackageName { |
<module name="PackageName"> |
include |
include tag |
#include |
<include file="PrimitiveTypes.xml"/> |
@key annotation 1For information on this and the other annotations, see Using Builtin Annotations (Section 1.0.1 on page 1). |
key attribute with values Default (if not present): 0 |
struct KeyedPrimitiveStruct { @key short short_member; }; |
<struct name="KeyedPrimitiveStruct"> |
@external or pointer |
external attribute with values true, false, 0, or 1 Default (if not present): 0 |
struct PrimitiveStruct { @external long long_member; }; |
<struct name="PointerStruct"> <member name="long_member" type="long" external="true"/> </struct> |
@optional annotation |
optional attribute with values true, false, 0 ,or 1 Default (if not present): 0 |
struct Point { long x; long y; @optional long z; }; |
<struct name= "Point"> <member name="x" type="int32"/> <member name="y" type="int32"/> <member name="z" type="int32" optional="true"/> </struct> |
@id annotation |
id attribute Default (if not present): id calculated based on the @autoid value of the enclosing type and module(s) |
@mutable struct Point { @id(56) long x; @id(57) long y; long z; }; |
<struct name="Point" extensibility="mutable"> <member name="x" id="56" type="long"/> <member name="y" id="57" type="long"/> <!-- z id is 58 --> <member name="y" type="long"/> </struct> |
@hashid annotation |
hashid attribute containing the string that must be hashed to compute the id Default (if not present). id calculated based on the @autoid value of the enclosing type and module(s) |
@mutable struct Point { @hashid long x; @hashid(“other_y”) long y; }; |
<struct name= "Point" extensibility= "mutable"> <member name="x" hashid="x" type="int32"/> <member name="y" hashid="other_y" type="int32"/> </struct> |
@value annotation |
value attribute Default (if not present): value of the previous enumerator plus 1 |
enum PrimitiveEnum { @value (10) ENUM1, @value (20) ENUM2, ENUM3 } |
<enum name="PrimitiveEnum"> <enumerator name="ENUM1" value="10"/> <enumerator name="ENUM2" value="20"/> <!-- ENUM3 id is 21 --> <enumerator name="ENUM3"/> </enum> |
@default_literal annotation |
defaultLiteral attribute with values true, false, 0, or 1 Default (if not present): 0 |
enum MyEnum { ENUM1, @default_literal ENUM2 }; |
<enum name="MyEnum"> <enumerator name="ENUM1"/> <enumerator name="ENUM2" defaultLiteral="true"/> </enum> |
@default annotation |
default attribute Default (if not present in this member or its alias types): 0, the empty string, or whichever enumerator is the defaultLiteral |
@default(24) typedef long MyLongTypedefWithDefault; struct Point { @default(42) long x; MyLongTypedefWithDefault y; }; |
<typedef name="MyLongTypedefWithDefault" type="long" default="24"/> <struct name="Point"> <member name="x" type="long" default="42"/> <member name="y" type="nonBasic" nonBasicTypeName="MyLongTypedefWithDefault"/> <!-- default is 24 --> </struct> |
@min annotation |
min attribute Default (if not present in this member or its alias types): the minimum possible value of the type |
struct Point { @min(-32) long x; long y; }; |
<struct name="Point"> <member name="x" type="long" min="-32"/> <member name="y" type="long"/> </struct> |
@max annotation |
max attribute Default (if not present in this member or its alias types): the maximum possible value of the type |
struct Point { @max(31) long x; long y; }; |
<struct name="Point"> <member name="x" type="long" max="31"/> <member name="y" type="long"/> </struct> |
@range annotation |
Not supported. Use min and max attributes instead. |
struct Point { @range(min = -32, max = 31) long x; long y; }; |
<struct name="Point"> <member name="x" type="long" min="32" max="31"/> <member name="y" type="long"/> </struct> |
@autoid annotation |
autoid attribute with "hash" or "sequential" values Default (if not present): the @autoid value in ancestor module(s) or sequential if not specified |
@mutable @hashid(HASH) struct Point { long x; long y; }; |
<struct name="Point" extensibility="mutable" autoid="hash"> <member name="x" type="long"/> <member name="y" type="long"/> </struct> |
@nested or @top-level annotation |
nested attribute with values true, false, 0 ,or 1 Default (if not present): 0 |
@nested struct or @top_level(false) struct TopLevelPrimitiveStruct { |
<struct name= "TopLevelPrimitiveStruct" nested="true"> <member name= "short_member" type="short"/> </struct> |
@extensibility, @mutable, @appendable, or @final annotation |
extensibility attribute with values final, appendable, or mutable Default (if not present): appendable |
@mutable struct Point { long x; long y; }; |
<struct name="Point" extensibility="mutable"> <member name="x" type="long"/> <member name="y" type="long"/> </struct> |
@allowed_data_representation |
allowed_data_representation attribute with values xcdr, xcdr2, or xml Default (if not present): xcdr2 for FlatData language binding; the @allowed_data_representation value in ancestor module(s) or (xcdr|xcdr2) for plain language binding |
@allowed_data_representation(XCDR2) @mutable struct Point { long x; long y; }; |
<struct name= "Point" extensibility= "mutable" allowed_data_representation="xcdr2"> <member name="x" type="int32"/> <member name="y" type="int32"/> </struct> |
@use_vector |
useVector attribute with values true, false, 0 ,or 1 Default (if not present): false unless code generated with -alwaysUseStdVector |
struct Image { @use_vector sequence<octet, 1048576> pixels; }; |
<struct name= "Image"> <member name="pixels" sequenceMaxLength="1048576" useVector="true" type="byte"/> </struct> |
@language_binding annotation |
languageBinding attribute with values plain or flat_data. Default (if not present): the @language_binding value in ancestor module(s) or plain if not specified |
@language_binding(FLAT_DATA) @final struct Point { long x; long y; }; |
<struct name="Point" extensibility=”final” languageBinding="flat_data"> <member name="x" type="long"/> <member name="y" type="long"/> </struct> |
@transfer_mode annotation |
transferMode attribute with values inband or shmem_ref. Default (if not present): the @transfer_mode value in ancestor module(s) or inband if not specified |
@transfer_mode(SHMEM_REF) struct Point { long x; long y; }; |
<struct name="Point" transferMode="shmem_ref"> <member name="x" type="long"/> <member name="y" type="long"/> </struct> |
@resolve-name annotation |
resolveName attribute with values true, false, 0, or 1 Default (if not present): @resolve_name of the parent type or false if not specified on parent |
struct @resolve_name(false) PrimitiveStruct |
<struct name= |
Other annotations |
directive tag |
//@copy (This text will be |
<directive kind="copy"> |
© 2020 RTI