Defining Type With A Non-Primitive (Custom Struct) Member In XML

6 posts / 0 new
Last post
Offline
Last seen: 5 years 12 months ago
Joined: 05/16/2017
Posts: 6
Defining Type With A Non-Primitive (Custom Struct) Member In XML

Hello,

I am recently working with RTI Connext DDS Connector in NodeJS and NodeRed. This has introduced me to XML application configuration and I have now come across the need to define a type which features, as a member, another struct.

In IDL, this has been no problem in the past. Now I am trying to do the same in XML but am encountering errors at run-time:

 

DDS_TypeCodeFactory_clone_tc_no_mem:ERROR: Bad parameter: tc_in
DDS_TypeCodeFactory_clone_tc:!clone typecode (0x7fffffeb)
DDS_TypeCode_add_member_ex:!cloning member type code
DDS_XMLTypeCode_process_member:Parse error at line 123: error adding member to type

 

DDS_XMLStruct_on_start_tag:error processing struct member
RTIXMLParser_parseFromFile:Parse error in file 'USER_QOS_PROFILES.xml'
DDS_XMLParser_parse_from_file:Error parsing file
DDS_QosProvider_load_profiles_from_current_dirI:ERROR: loading profiles file 'USER_QOS_PROFILES.xml'
DDS_QosProvider_load_profilesI:ERROR: loading profiles
DDS_DomainParticipantFactory_load_profilesI:!load profiles
DDS_DomainParticipantFactory_create_participant_from_config_w_paramsI:ERROR: loading profiles
DDSDomainParticipantFactory::create_participant_from_config:!create DomainParticipant from configuration "MyParticipantLibrary::MyPubParticipant"
create_participant_from_config error

And the XML:

 

<struct name="ihub_s" extensibility="extensible">
<member name="dm" type="string" stringMaxLength="16" />
</struct>

<struct name="local_s" extensibility="extensible" >
<member name="msg" type="string" stringMaxLength="32" />
<member name="source" type="string" stringMaxLength="32" />
</struct>

<struct name="meta_s" extensibility="extensible">
<member name="locals" type="local_s" /> <!-- This is line 123 which fails -->
<member name="ihub" type="ihub_s" />
</struct>

<struct name="xbw_ihub_t" extensibility="extensible">
<member name="ddsMsgId" type="long" />
<member name="value" type="long" />
<member name="type" type="string" stringMaxLength="8" />
<member name="meta" type="meta_s" />
</struct>

And, for clarification, the IDL:

 

module data{


struct ihub_s{
string dm;
};

struct local_s{
string msg;
string source;
};

struct meta_s{
local_s locals;
ihub_s ihub;
};

struct xbw_ihub_t{
long ddsMsgId;//@key
long value;
string type;
meta_s meta;
};
};

 

 

Is there something I have missed, or are nested types like this not supported in XML configuration?

Thank you very much in advance,

Any and all help much appreciated.

 

Edit: IDL and XML snippets have been updated. The IDL compiles as expected.

The name "local" in the struct "meta_s" was likely to have thrown problems, so has now been altered, but the application still fails at line 123 of the xml.

Fernando Garcia's picture
Offline
Last seen: 5 months 2 weeks ago
Joined: 05/18/2011
Posts: 200

Hi Odie,

Do you have access to rtiddsgen? Aside from generating code, the utility can also convert IDL files into XML format. To convert your IDL file into XML run rtiddsgen as follows:

rtiddsgen -convertToXml type.idl

It will generate a file with the files converted that you can use in the XML configuration file you are using in Connector.

<types>
  <module name="data">
    <struct name= "ihub_s">
      <member name="dm" type="string"/>
    </struct>
    <struct name= "local_s">
      <member name="msg" type="string"/>
      <member name="source" type="string"/>
    </struct>
    <struct name= "meta_s">
      <member name="locals" type="nonBasic"  nonBasicTypeName= "data::local_s"/>
      <member name="ihub" type="nonBasic"  nonBasicTypeName= "data::ihub_s"/>
    </struct>
    <struct name= "xbw_ihub_t">
      <member name="ddsMsgId" type="int32" key="true"/>
      <member name="value" type="int32"/>
      <member name="type" type="string"/>
      <member name="meta" type="nonBasic"  nonBasicTypeName= "data::meta_s"/>
    </struct>
  </module>
</types>

Note members of non-basic types such as locals need to be declared as membres of  type="nonBasic" where nonBasicTypeName="data::local_s".

Please let me know if this solves your issue.

Thanks,
Fernando.

Offline
Last seen: 5 years 12 months ago
Joined: 05/16/2017
Posts: 6

Hello Fernando, thank you for your response.

Firtly, yes, setting the type correctly to "nonBasic" and including the nonBasicTypeName fixed our issue and all is working as expected now - wonderful. And I really appreciate the note about using rtiddsgen and the -convertToXml flag - I hadn't even thought of doing that!

 

Thanks again for your help

Offline
Last seen: 5 years 12 months ago
Joined: 05/16/2017
Posts: 6

Hello again, Fernando,

I'm not sure if you'll see this here, now that the original issue has been resolved, and I'm sorry for restarting this thread, but I just have one more question with regards to your answer: is there a reason that int32 was used for the numeric types, as opposed to long?

Either is fine - I'm just used to working in IDL and using long for numeric types (as per the Translations For IDL Types document) and am curious if this is different for xml defined types? I couldn't find mention of int32 in the Creating User Data Types With Extensible Markup Language document.

Thanks again,

Odie

Fernando Garcia's picture
Offline
Last seen: 5 months 2 weeks ago
Joined: 05/18/2011
Posts: 200

Hi Odie,

You can use both long and int32. The former matches the IDL notation as is probably there for historical reasons and convenience, because it easier for people that are used to IDL. The latter, matches the standard XSD type representation defined in the OMG DDS-XTYPES specification.

As far as I know, RTI Connext DDS supports both notations so you can use either one. I think the next version of rtiddsgen is going to use int32 when running -convertToXml to better align with the DDS-XTYPES specification.

Thanks,
Fernando.

Offline
Last seen: 6 years 3 months ago
Joined: 07/23/2018
Posts: 20

I have a similar sort of an issue, I am using the rtiddsgen utility to convert IDL into xml and I also have keywords 'module' present. During runtime, it is unable to parse the keyword module. However, If i remove 'module' from my xml, it works fine. Any idea ? I have already posted a issue https://community.rti.com/forum-topic/error-parsing-xml-file-when-keyword-module-present