我发现了一些与 xinclude 相关的问题,但没有一个专门回答我关于如何包含外部文档的基本问题
这里有几个我想互相参考的 xml 文档:
<?xml version="1.0" encoding="UTF-8"?>
<t:person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://test test-schema.xsd"
xmlns:t="http://test">
<t:first-name>Wilma</t:first-name>
<t:last-name>Flintstone</t:last-name>
<t:spouse>
<xi:include xmlns:xi="http://www.w3.org/TR/xinclude" href="fred.xml"/>
</t:spouse>
</t:person>
<?xml version="1.0" encoding="UTF-8"?>
<t:person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://test test-schema.xsd"
xmlns:t="http://test">
<t:first-name>Fred</t:first-name>
<t:last-name>Flintstone</t:last-name>
<t:spouse>
<xi:include xmlns:xi="http://www.w3.org/TR/xinclude" href="wilma.xml"/>
</t:spouse>
</t:person>
和架构:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://test"
targetNamespace="http://test" elementFormDefault="qualified">
<xs:element name="person" type="personType"/>
<xs:complexType name="personType">
<xs:sequence>
<xs:element name="first-name" type="xs:string"/>
<xs:element name="last-name" type="xs:string"/>
<xs:element name="spouse" type="personType"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
xi:include 元素出现无效。我一直在四处寻找,找不到像这样的简单示例。xi:include 只是应该存在的元素的替代品,对吗?
谢谢,bp