我编写了一个类似下面的XMLSchema。其想法是,basecontainer只允许一些标记,而fullcontainer允许basecontainer+中的所有标记。标签可以按任意顺序排列,并且可以有多个标签。在我的实际示例中,有更多的标记,因此这种编写XMLSchema的方法趋向于变得大型和非结构化。我想使用xmlschema扩展标记来构造文档,但它并不像我期望的那样工作。
事先谢谢:)
<complexType name="baseContainer">
<sequence minOccurs="0" maxOccurs="unbounded">
<choice minOccurs="0" maxOccurs="1">
<element ref="w:aTag0"/>
<element ref="w:aTag1"/>
<element ref="w:aTag2"/>
</choice>
</sequence>
</complexType>
<complexType name="fullContainer">
<sequence minOccurs="0" maxOccurs="unbounded">
<choice minOccurs="0" maxOccurs="1">
<element ref="w:aTag0"/>
<element ref="w:aTag1"/>
<element ref="w:aTag2"/>
<element ref="w:aTag3"/>
<element ref="w:aTag4"/>
</choice>
</sequence>
</complexType>
我尝试过:
<complexType name="fullContainer">
<complexContent>
<extension base="w:baseContainer">
<sequence minOccurs="0" maxOccurs="unbounded">
<choice minOccurs="0" maxOccurs="1">
<element ref="w:aTag3"/>
<element ref="w:aTag4"/>
</choice>
</sequence>
</extension>
</complexContent>
</complexType>