Error parsing the xml file when a keyword module is present.

6 posts / 0 new
Last post
Offline
Last seen: 6 years 3 months ago
Joined: 07/23/2018
Posts: 20
Error parsing the xml file when a keyword module is present.

I am using RTI DDS Connector for Python

I have an IDL file which I converted to an .xml file to use DDS's XML Application creation.

 

<types>

<module name= "DetectedObject_msgs_">
<struct name="DetectedObject_" extensibility="extensible">
<member name="id_" id="0" type="long" key="true"/>
<member name="x_" id="1" type="float"/>
<member name="y_" id="2" type="float"/>
<member name="v_rad_" id="3" type="float"/>
<member name="a_rad_" id="4" type="float"/>
</struct>
</module>



<struct name="DetectedObjectList_">
<member name="id_" id="5" type="float"/>
<member sequenceMaxLength="-1" name="objects_" type="nonBasic" nonBasicTypeName="DetectedObject_"/>
<member name="header_" id="7" type="long"/>
</struct>

 


</types>

 

My problem is that the IDL and thus the xml has the keyword 'module'. If I take out this keyword, everything works fine but the xml is unable to parse the keyword module.

Any help would be appreciated :)

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

It's been a while now since I was working with the xml application configuration, so not sure how correct I will be with what I say here. There's a good chance things may have changed, it was a year ago now. That being said, I've just opened the old project files (snippets of which you saw in my old topic)  and I have found no reference to the "module" keyword - so my thinking (guessing at this point, really) is it's not required in xml.

Below is a snippet of the <types> section I got working in an XML definition used with the RTI node-red flow. Note no use of modules.

<types>
         <const name="MAX_NAME_LEN" type="long" value="64"/>
         <const name="MAX_MSG_LEN"  type="long" value="128"/>

         <struct name="HelloWorld" extensibility="extensible">
            <member name="sender"  type="string"  key="true"   stringMaxLength="MAX_NAME_LEN"/>
            <member name="message" type="string"               stringMaxLength="MAX_MSG_LEN"/>
             <member name="count"   type="long"/>
          </struct>

    <struct name="JSButtonData" extensibility="extensible">
        <member name="msgID"     type="long"   key="true" />
        <member name="buttonID" type="long" />
        <member name="value"     type="string" stringMaxLength="24" />
    </struct>        
</types>


Also - I would highly advise following the advice of @Fernando Garcia in my topic:

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 

Using that line, you should be able to provide rtiddsgen with your IDL file (assuming it's correctly formed) and will receive a correcty formed XML translation.

 

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

Thank you for your prompt response. 

Yes, I am already using the rtiddsgen utility to convert my IDL file into xml as already mentioned. My IDL files already have a 'module' keyword. So once I convert it to an xml, this keyword is present there as well. So in that case, I need to remove it manually from the entire file.

This is why I am looking for a possibility to parse 'module' keyword.

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

You haven't yet said what's actually going wrong? What error are you encountering which makes you think the word 'module' is the problem?

If it produces the XML with the 'module' keyword, I would assume that it poses no problem to application and should be parsed. As I said, it's been a while since I've looked at XML application definition so can't be sure. I've just tried running another of my IDL files through rtiddsgen and seen that it does add the module keyword to the type definitions.

I'm clutching at straws here (especially as  I don't know what your error is), but I see you've not included the namesapce for the module in your types definition. You could try something like:

<types>
  <module name= "DetectedObject_msgs_">
    <struct name="DetectedObject_" extensibility="extensible">
      <member name="id_" id="0" type="long" key="true"/>
      <member name="x_" id="1" type="float"/>
      <member name="y_" id="2" type="float"/>
      <member name="v_rad_" id="3" type="float"/>
      <member name="a_rad_" id="4" type="float"/>
   </struct>

  </module>

  <struct name="DetectedObjectList_">
    <member name="id_" id="5" type="float"/>
    <member sequenceMaxLength="-1" name="objects_" type="nonBasic" nonBasicTypeName="DetectedObject_msgs_::DetectedObject_"/>
     <member name="header_" id="7" type="long"/>
  </struct>
</types>


  Notice the addition of "DetectedObject_msgs_::" in the nonBasicTypeName attribute. This is the name of the module followed by the :: operator. This tells the applicaiton in which module to look for the type.

 

EDIT: Also just noticed your "sequenceMaxLength = -1". Is this intended? Clutching at straws again as I'm not sure but it felt like something to point out.

EDIT2: I looked through the XML which has been generated from rtiddsgen on one of the IDL files I'm currently using. The "module" definitions have all been reproduced, but they are all also included in the nonBasicTypeName attributes. The example line below is taken straight from the generated XML file, and shows the generated "member" for a type which is defined in another module

<member name="category" type="nonBasic"  nonBasicTypeName= "DataModel::MessageCatagory_E" key="true"/>

EDIT3: For completeness, here's more of the snippet from which the previous line was taken. It has all been produced by rtiddsgen and I haven't edited any of it. I've not tested it, either, so can't guarantee that it will work but would expect it to. If you're not seeing the addition of "moduleName::typeName", are you sure the IDL is correct?
<types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="/path/to/RTIInstall/rti_connext_dds-5.2.3/bin/../resource/app/app_support/rtiddsgen/schema/rti_dds_topic_types.xsd">
<module name="DataModel">
  <enum name="MessageCatagory_E">
    <enumerator name="MSG_STS_SENSOR_RF"/>
    <enumerator name="MSG_STS_SENSOR_NAVIGATION"/>
    <enumerator name="MSG_STS_LOCATION"/>
    <enumerator name="MSG_STS_VIDEO"/>

    <module name="DataInputMonitor">
      <struct name= "DIM_t">
        <member name="msgId" type="longLong" key="true"/>
        <member name="messageCatagory" type="nonBasic"  nonBasicTypeName= "DataModel::MessageCatagory_E"/>
      </struct>
    </module>

</module>
</types>

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

Hi, Thank you for the explanation. I did not post some of the information and that is the reason for the confusion.

Lets start a fresh with a simple example :

This is the IDL :

module std_msgs

{

module msg

{

module dds_

{

struct String_

{

  String data_;

};

};

};

};

 

Now I use the RTIDDSgen utility to convert it into xml and this is the xml i get :

<?xml version="1.0" encoding="UTF-8"?>

<types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="/path/to/RTIInstall/rti_connext_dds-5.2.3/bin/../resource/app/app_support/rtiddsgen/schema/rti_dds_topic_types.xsd">

<module name="std_msgs">

<module name="msg">

<module name="dds_">

<struct name="String_">

<member name="data_" type="string"/>

</struct>

</module>

</module>

</module>

</types>

No When I try to use the RTi Connector for python and load this xml file it gives me an error stating : File could not be parsed.

I am pretty sure it is because of the module keyword.

Do you have any idea ?

 

 

 

 

 

 

 

Offline
Last seen: 1 year 1 month ago
Joined: 01/01/2017
Posts: 15

FWIW, if I translate your IDL using rtiddsgen, I get an error:

rtiddsgen -language C++ std_msgs.idl
INFO com.rti.ndds.nddsgen.Main Running rtiddsgen version 2.3.3, please wait ...
ERROR com.rti.ndds.nddsgen.Main std_msgs.idl line 16:2 member type 'String' not found
ERROR com.rti.ndds.nddsgen.Main Fail: The file couldn't be parsed and the rawTree wasn't generated
INFO com.rti.ndds.nddsgen.Main Done (failures)

After changing "String" to "string" at the member data_, it works:

struct String_
{ 
   string data_;
};