我必须创建一个复合XML文档,将两个词汇表中的元素和属性组合在一起。我需要为复合文档创建一个组合模式,并确认复合文档通过了验证。我将这两个词汇文档放在一个文档中。我不确定如何创建组合模式。
<!--Vocabulary1S
-->
<reg:smartphones xmlns:reg="http://example.com/smartphones/vocab"
reg:schemaLocation="http://example.com/smartphones/vocab/ns vocab1schema.xsd">
<reg:choices>Smart Phones
<reg:phones>
<!-- skip-->
<!--Vocabulary2 -->
<plu:smartphones xmlns:plu="http://example.com/smartphones/vocab"
plu:schemaLocation="http://example.com/smartphones/vocab/ns vocab2schema.xsd">
<plu:pluschoices>Plus Size Choices
<plu:bigphones>
<plu:bigphone>
<!-- not complete code, end of doc-->
<!--start of combined schema Vocab1Schema -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:cc="http://example.com/smartphones/vocab/ns"
targetNamespace="http://example.com/smartphones/vocab/ns"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="SmartPhones">
<!-- Vocab2Schema -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://example.com/smartphones/vocab/ns"
elementFormDefault="qualified" attributeFormDefault="unqualified"
>
<xs:element name="SmartPhones">
<xs:complexType mixed="true">发布于 2019-03-26 17:19:59
如果两个模式文档包含具有相同targetNamespace的定义,则只需使用
<xs:schema targetNamespace="...">
<xs:include schemaLocation="schema1.xsd"/>
<xs:include schemaLocation="schema2.xsd"/>
</xs:schema>如果您有冲突的定义,例如,如果两个模式文档包含冲突的"SmartPhones“元素的定义,这将显示一个错误。如果这两个模式存在这样的冲突,则无法组合这两个模式(或在同一实例文档中引用它们);您必须首先将其中一个实例文档和一个模式转换为不同的名称空间。
https://stackoverflow.com/questions/55349398
复制相似问题