2
我有以下的XML SchemaXML模式:這樣的選擇,是工會(不是序列)創建
<xsd:complexType name="SimpleThing">
<xsd:choice maxOccurs="unbounded">
<xsd:group ref="simpleContent" />
</xsd:choice>
</xsd:complexType>
<xsd:complexType name="ExtendedThing">
<xsd:complexContent>
<xsd:extension base="SimpleThing">
<xsd:choice maxOccurs="unbounded">
<xsd:element name="qux" />
</xsd:choice>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:group name="simpleContent">
<xsd:choice>
<xsd:element name="foo" />
<xsd:element name="bar" />
</xsd:choice>
</xsd:group>
<xsd:group name="extendedContent">
<xsd:choice>
<xsd:group ref="simpleContent" />
<xsd:element name="qux" />
</xsd:choice>
</xsd:group>
<xsd:element name="root" type="ExtendedThing" />
我喜歡的類型ExtendedThing
包含foo
,bar
和qux
以任意順序選擇:擴展XSD 。但是對於這種模式,qux
必須出現在foo
和bar
之後,因爲從超類型的選擇和子類型的選擇中創建了一個序列,而不是這些選擇的聯合。
另一種方法,用
<xsd:complexType name="ExtendedThing">
<xsd:complexContent>
<xsd:extension base="SimpleThing">
<xsd:group ref="extendedContent" />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
更換爲ExtendedThing
類型定義也不管用,因爲Unique Particle Attribution違反約束。
有沒有解決這個問題的方法,或者是否可以在XML模式中創建一個類型,這是另一種類型的擴展,這樣新類型的內容就是一組元素(以任意順序)超類型內容的超集?
請參閱:http://stackoverflow.com/questions/9008622/how-to-extend-a-choice-complextype-without-sequencing-the-choice – albciff 2014-08-29 09:50:20