我想合并2个具有相同结构的XML文件来制作一个.例如;
Test1.xml
<?xml version="1.0" encoding="UTF-8"?>
<ns:Root
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns="urn:TestNamespace"
xsi:schemaLocation="urn:Test.Namespace Test1.xsd"
>
<ns:element1 id="001">
<ns:element2 id="001.1" order="1">
<ns:element3 id="001.1.1" />
</ns:element2>
<ns:element2 id="001.2" order="2">
<ns:element3 id="001.1.2" />
</ns:element2>
</ns:element1>
</ns:Root>
Run Code Online (Sandbox Code Playgroud)
和Test2.xml
<?xml version="1.0" encoding="UTF-8"?>
<ns:Root
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns="urn:TestNamespace"
xsi:schemaLocation="urn:Test.Namespace Test1.xsd"
>
<ns:element1 id="999">
<ns:element2 id="999.1" order="1">
<ns:element3 id="999.1.1" />
</ns:element2>
</ns:element1>
</ns:Root>
Run Code Online (Sandbox Code Playgroud)
创造
TestOutput.xml
<?xml version="1.0" encoding="UTF-8"?>
<ns:Root
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns="urn:TestNamespace"
xsi:schemaLocation="urn:Test.Namespace Test1.xsd"
>
<ns:element1 id="001">
<ns:element2 id="001.1" order="1">
<ns:element3 id="001.1.1" />
</ns:element2>
<ns:element2 id="001.2" order="2">
<ns:element3 id="001.1.2" />
</ns:element2>
</ns:element1>
<ns:element1 …Run Code Online (Sandbox Code Playgroud) 是否有任何支持XPointer的java库与xpointer()方案?
Xerces支持使用XPointer Framework和XPointer element()方案的XInclude,但不支持xpointer()方案.
关于xpointer()模式的最新W3C文档来自2002年,但仍然只是一个草案:http://www.w3.org/TR/xptr-xpointer/
我有一个包含 2 个 'sub_x.xml' 文件的 'main.xml' 文件。包含行使用“xpointer”来仅指向/包含包含 xml 的特定标签。当我使用 ElementTree 来确定这是否正常工作时,它表明包含了整个“sub”xml 文件,而不仅仅是我想要的标签。我不确定我是否错误地使用了 xpointer 或者 ElementTree 或 ElementInclude 不支持这一点。以下是文件:
------'main.xml'--------
`<?xml version='1.0' encoding='utf-8'?>
<ModelInfo xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="sub_1.xml" xpointer="xpointer(//ModelInfo/Model)" parse="xml" />
<xi:include href="sub_2.xml" xpointer="xpointer(//ModelInfo/Model)" parse="xml" />
</ModelInfo>`
Run Code Online (Sandbox Code Playgroud)
-------'sub_1.xml'------
`<?xml version="1.0" ?>
<ModelInfo>
<Model ModelName="glow">
<Variables>
<Variable Alias="glow_val" Input="False" Output="True" />
</Variables>
</Model>
</ModelInfo>`
Run Code Online (Sandbox Code Playgroud)
-------'sub_2.xml'------
`<?xml version='1.0' encoding='utf-8'?>
<ModelInfo>
<Model ModelName="sirpwr_b_supply8v1">
<Variables>
<Variable Alias="sirpwr_a_supplyecu_Snsr8vIstat" Input="True" Output="False" />
</Variables>
</Model>
</ModelInfo>`
Run Code Online (Sandbox Code Playgroud)
我希望 'main.xml' 在 ElementTree 中显示为:
`<?xml version='1.0' encoding='utf-8'?>
<ModelInfo xmlns:xi="http://www.w3.org/2001/XInclude">
<Model ModelName="glow">
<Variables> …Run Code Online (Sandbox Code Playgroud) 简单XLink到同一文档中另一个节点的一般要点似乎是:
<root xmlns:xlink="http://www.w3.org/1999/xlink">
<firstChild id="ID1" />
...
<ref xlink:href="#ID1" />
</root>
Run Code Online (Sandbox Code Playgroud)
不使用XPointer或XPath,这与XLink一样多吗?你能不能做一个XLink,比如说是一个customId看起来像的东西:
<root xmlns:xlink="http://www.w3.org/1999/xlink">
<firstChild id="ID1" customId="{1234-5678}" />
...
<ref xlink:href="#customId/{1234-5678}" />
</root>
Run Code Online (Sandbox Code Playgroud)
请不要仅仅参考我的W3规范 - 我不了解你,但需要一个特殊的人来解释它们,我今天不是那个人!
无论如何,据我所知,大多数XLink似乎都是关于引用外部资源,而且我见过的大多数例子都使用http链接到网络资源......我只是好奇你可以用XLink做什么来引用XML文档中的特定部分.
谢谢!
我想编写一个标识特定HTML页面上所有链接的函数.我的想法是使用XPath,通过使用路径,如//body//a[x]增加x来遍历页面上的第一,第二,第三个链接.
在Chrome中尝试此操作时,我会加载页面http://exoplanet.eu/,并在Chrome Developer Tools JS控制台中调用$x("//body//a[1]").我期待页面上的第一个链接,但这会返回多个锚元素的列表.调用$x("//body//a[2]")返回两个锚元素.呼叫$x("//body//a[3]")什么都不返回.
我希望[x]每次递增会在页面上逐一给出每个唯一的链接,但它们似乎是分组的.我怎样才能重写这条路径,以便逐一挑选每个锚标签?
我正在尝试使用Jena框架处理RDF 的工具(Elda).
我收到了这个错误:
错误[qtp1415899750-24](RouterRestlet.java:332) - 异常:第7行,第72列:com.hp.hpl.jena.iri.impl.IRIImplException:代码:0/ILLEGAL_CHARACTER在FRAGMENT中:该字符违反了语法规则对于URI/IRI.
它说以下URL不是有效的IRI.
http://burckhardt.netseven.it/show_annotable_transcription?id=12#xpointer(start-point(string-range(//DIV[@about='http://burckhardt.netseven.it/show_annotable_transcription?id=12' ]/DIV [1]/BLOCKQUOTE [1]/P [1] /文本()[1], '',13))/范围 - (字符串范围(// DIV [@约=的"http:/ /burckhardt.netseven.it/show_annotable_transcription?id=12']/DIV[1]/BLOCKQUOTE[1]/P[1]/text()[1],'',27)))
我知道它很丑,但据我所知,它符合XPointer规范......而且我在其他环境中成功使用它(例如Sesame triplestore).
有人弄错了吗?
谢谢
基督教
我试图使用 xi:include 将 a.xml 元素的所有子元素(部分)包含到 b.xml 中。这两个 XML 文件都是有效的 docbook 5 文件。
xml文件
<chapter xml:id="TheChapter">
<section>
<title>section 1</title>
</section>
<section>
<title>section 2</title>
</section>
<section>
<title>section 3</title>
</section>
</chapter>
Run Code Online (Sandbox Code Playgroud)
b.xml
<section>
<xi:include href="a.xml" xpointer="element(/TheChapter/*)"/>
</section>
Run Code Online (Sandbox Code Playgroud)
我正在使用 XMLMind,它报告错误。
cannot parse inclusion directive: cannot parse XPointer "element(/TheChapter/*)": "/TheChapter/*", XPointer element() scheme syntax error
Run Code Online (Sandbox Code Playgroud)
我对 element() 方案的使用不正确吗?