我尝试使用xi:include将元素的所有子元素(部分)从a.xml包含到b.xml中。这两个XML文件都是有效的docbook 5文件。
a.xml
<chapter xml:id="TheChapter">
<section>
<title>section 1</title>
</section>
<section>
<title>section 2</title>
</section>
<section>
<title>section 3</title>
</section>
</chapter>b.xml
<section>
<xi:include href="a.xml" xpointer="element(/TheChapter/*)"/>
</section>我使用的是报告错误的XMLMind。
cannot parse inclusion directive: cannot parse XPointer "element(/TheChapter/*)": "/TheChapter/*", XPointer element() scheme syntax error我使用element()方案是不是不正确?
发布于 2014-10-05 18:57:29
您对element()方案的使用不正确。
通过ID标识元素的表达式的第一部分不应以正向符号(
*)开头不能使用。“子序列”只能包含正斜杠和数字。这是一个有效的表达式:
element(TheChapter/1)它将选择由TheChapter ID标识的元素的第一个子元素。使用element()方案无法完成您想要的操作。
您可以使用xpointer()方案:
xpointer(id('TheChapter')/*)xpointer()方案从未成为W3C推荐标准(它仍然只是一个草案),也没有得到广泛的实现。
XMLmind XML编辑器不支持xpointer()的一个子集。这里有一个邮件列表帖子,里面有更多细节:http://permalink.gmane.org/gmane.editors.xxe.general/10220。
发布于 2014-10-09 17:03:38
以下用法可以很好地工作:
<xi:include href="a.xml" xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('TheChapter')/db:section)"/>或
<xi:include href="a.xml" xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('TheChapter')/*)"/>https://stackoverflow.com/questions/26178742
复制相似问题