X包含使用多个冒号的urn

时间:2017-08-28 18:38:20

标签: xml xmllint xinclude

基于How to use xpointer with Xinclude to reference elements ...

当命名空间urn包含多个冒号时,我遇到了包括使用xpointer的嵌套元素的问题。

Test1.xml

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

<Root xmlns="urn:some:namespace">
  <element1 id="001">
    <element2 id="001.1" order="1">
      <element3 id="001.1.1"/>
    </element2>
    <element2 id="001.2" order="2">
      <lement3 id="001.1.2"/>
    </element2>
  </element1>
</Root>

Test2.xml

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

<Root>
  <element1 id="999">
    <element2 id="999.1" order="1">
      <element3 id="999.1.1"/>
    </element2>
  </element1>
</Root>

的merge.xml

<?xml version="1.0"?>

<Root xmlns:xi="http://www.w3.org/2003/XInclude">

  <xi:include href="Test1.xml" xpointer="xmlns(ns=urn:some:namespace)xpointer(/ns:Root/ns:element1)" parse="xml" />
  <xi:include href="Test2.xml" xpointer="xpointer(//Root/element1)" parse="xml" />

</Root>

命令:

xmllint --pretty 1 --xinclude Merge.xml

错误

Merge.xml:5: element include: XInclude error : XPointer evaluation failed: #xmlns(ns=urn:some:namespace)xpointer(/ns:Root/ns:element1)
Merge.xml:5: element include: XInclude error : could not load Test1.xml, and no fallback was found

0 个答案:

没有答案