【问题标题】:RTI XMLParser error because of environment variables由于环境变量,RTI XMLParser 错误
【发布时间】:2021-04-06 15:14:10
【问题描述】:

我正在使用 xml 文件来创建消息定义。

我的 xml 文件如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<dds>
<types>
  <include file="home/a.shah/AR/rpc_types.xml"/>
    <module name="idl">
      <module name="test">
        <module name="Calculator">
          <struct name= "AdditionRequest" baseType="rpc::Request">
            <member name="value1" type="int32"/>
            <member name="value2" type="int32"/>
          </struct>
          <struct name= "AdditionReply" baseType="rpc::Reply">
            <member name="result" type="int32"/>
          </struct>
          <struct name= "MultiplicationRequest" baseType="rpc::Request">
            <member name="value1" type="int32"/>
            <member name="value2" type="int32"/>
          </struct>
          <struct name= "MultiplicationReply" baseType="rpc::Reply">
            <member name="result" type="int32"/>
          </struct>
        </module>
      </module>
  </module>
</types>
</dds>

我的$HOME 环境设置为/home/a.shah,因此我想替换该行

<include file="home/a.shah/AR......"/>

<include file="$HOME/AR/......"/>

但是,当我这样做时,我会遇到很多这样的错误:

DDS_XMLFileInfoList_assertFile:!open file: $HOME/AR/rpc_types.xml
DDS_XMLInclude_initialize:!assert file info DDS_XMLInclude_new:!init XML include object RTIXMLParser_onStartTag:Parse error at line 4: Error processing tag 'include' RTIXMLParser_parseFromFile_ex:Parse error in file 'tests/data/CalculatorService.xml' DDS_XMLParser_parse_from_file:Error parsing file
DDS_QosProvider_load_profiles_from_urlI:ERROR: loading profiles file 'tests/data/CalculatorService.xml' 
DDS_QosProvider_load_profiles_from_url_groupI:ERROR: loading profiles 
DDS_QosProvider_load_profiles_from_url_listI:ERROR: loading profiles DDS_QosProvider_load_profiles_from_env_varI: ERROR: loading profiles DDS_QosProvider_load_profilesI:ERROR: loading profiles DDS_DomainParticipantFactory_load_profilesI:!load profiles DDS_DomainParticipantFactory_get_default_participant_qos:ERROR: loading profiles

请告诉我如何将/home/a.shah/AR 更改为$HOME/AR 而不会出现这些错误。

【问题讨论】:

标签: xml data-distribution-service


【解决方案1】:

解决方案是使用这样的圆括号

<types>
  <include file="$(HOME)/AR/ar-dds/idl/ar/dds/rpc/rpc_types.xml"/>
  ...
</types>

【讨论】:

  • 对于其他阅读本文的人,请记住 xml 不是 shell 或脚本语言,它是一种数据标记结构。假设 $HOME 从一开始就可以工作是一个糟糕的假设。是的,有一种格式允许它工作,但那是因为处理它的工具是为了理解 $ env var 约定而编写的——并非总是如此。
猜你喜欢
  • 2013-01-30
  • 2016-11-04
  • 1970-01-01
  • 2014-03-24
  • 2014-12-03
  • 2017-05-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多