我有以下两个具有相同命名空间的(不可更改的)文件,我需要为它创建一个XSD:
伪xml示例1:
<Project>
<ProjectInformation/>
<HistoryEntry/>
<UserFiles/>
</Project>伪xml示例2:
<Project>
<Installations/>
</Project>如果没有HistoryEntry和UserFiles元素,我将使用xsd:choice来表示ProjectInformation和Installations。但是如何将HistoryEntry和UserFiles元素引入游戏呢?!
是否有一个标准的XSD机制允许这样做?
发布于 2016-10-27 18:09:43
无序被高估了。只需使用xs:sequence而不是xs:any来避免XSD1.0中唯一的粒子属性冲突:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Project">
<xs:complexType>
<xs:choice>
<xs:sequence>
<xs:element name="ProjectInformation"/>
<xs:element name="HistoryEntry"/>
<xs:element name="UserFiles"/>
</xs:sequence>
<xs:element name="Installations"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>https://stackoverflow.com/questions/40291305
复制相似问题