How to include xml file in xml ? <xi :="" include="" does="" not="" work=""

时间:2017-08-04 13:15:13

标签: xml xinclude

="" I am trying to include some xml files in an other xml file. To do so, I used :

<example xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xi="http://www.w3.org/2001/XInclude">

        <xi:include href="file1.xml" parse="xml" />
        <xi:include href="file2.xml" parse="xml" />

    </types>

</example>

But i got this error : Unexpected attribute 'xmlns:xi'

I don't understand why...

Thanks in advance !

( I am using Node js and trying to connect to DDS By the way )

1 个答案:

答案 0 :(得分:1)

您需要检查XML解析器是否有扩展xi:include指令的选项。默认情况下不太可能完成,如果功能完全存在,您可能需要对其进行配置。

如果没有,你可能会找到一个独立的XInclude处理器,但我怀疑你在Node.js上的选择有点受限。

对于XInclude的非常小的子集,人们实际上99%的时间使用它,编写XSLT转换来进行扩展是非常微不足道的:它只有六个行的代码。