繁体   English   中英

如何在BeanIO中引用外部xml文件?

[英]How to reference external xml files in BeanIO?

我一直在阅读BeanIO的“模板”部分,但没有找到特定于带有模板的外部文件的内容。 基本上,我试图创建一个xml文件,该文件将保存我的所有模板并从其他文件引用一个特定的模板。

我有这个文件mytemplates.xml

<beanio>

    <template name="theTemplate">
        //template fields
    </template>
</beanio>

我还有另一个名为myfile.xml的文件,它将使用mytemplates.xml中的模板

<beanio>
    <stream name="aaa" format="fixedlength">
            <include template="theTemplate"/>
    </stream>
</beanio>

有没有办法做到这一点?

为了将来参考,我发现答案遍历了仓库,也有人在beanIO组中提到了它。 希望能帮助到你。

<beanio xmlns="http://www.beanio.org/2012/03" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.beanio.org/2012/03 http://www.beanio.org/2012/03/mapping.xsd">



<--I had to go up to package level to make it work ie: org/app/myapp/mytemplates.xml-->
  <import resource="classpath:mytemplates.xml"/>

  <!-- the rest of your file -->
</beanio>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM