0

我试图在另一个 xml 文件中包含一些 xml 文件。为此,我使用了:

<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>

但我得到了这个错误:意外的属性'xmlns:xi'

我不明白为什么...

提前致谢 !

(我正在使用 Node js 并尝试连接到 DDS 顺便说一句)


您需要仔细查看Quoting Constructs

在这种情况下,用尖括号或<{和将 LHS 中作为单独标记的部分括起来}>

my $a = 'abababa';
my $b = '^aba';
say so $a ~~ /<$b>/;       # True, starts with aba
say so $a ~~ /<{$b}>/;     # True, starts with aba

my $c = '<[0..5]>'
say so $a ~~ /<$c>/;       # False, no digits 1 to 5 in $a
say so $a ~~ /<{$c}>/;     # False, no digits 1 to 5 in $a

在此处输入图像描述

另一个故事是当您需要将变量传递给限制量词时。那就是您只需要使用大括号的地方:

my $ok = "12345678";
my $not_ok = "1234567";
my $min = 8;
say so $ok ~~ / ^ \d ** {$min .. *} $ /;         # True, the string consists of 8 or more digits
say so $not_ok ~~ / ^ \d ** {$min .. *} $ /;     # False, there are 7 digits only

在此处输入图像描述

4

1 回答 1

1

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

如果没有,您也许可以找到一个独立的 XInclude 处理器,但我怀疑您在 Node.js 上的选择有点有限。

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

于 2017-08-04T17:23:04.180 回答