我编写了一个不幸违反Unique Particle Attribution的模式。如何重写它以使其有效?
<xsd:complexType name="A">
<xsd:sequence>
<xsd:element name="elem" type="ex:B" minOccurs="0" />
<xsd:sequence minOccurs="0" maxOccurs="unbounded">
<xsd:element name="elem" type="ex:A" />
<xsd:element name="elem" type="ex:B" minOccurs="0" />
</xsd:sequence>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="B">
</xsd:complexType>
目标结构是<elem />
个交替类型ex:A
和ex:B
的序列,其中<elem />
类ex:B
是可选的。可能有任意数量的后续<elem />
类型ex:A
,但不能有<elem />
个ex:B
类型<elem />
没有类型ex:A
在他们之间{1}}。
架构应验证以下示例:
示例1:
<elem /> <!-- ex:B defines an empty element -->
<elem> <!-- some content according to ex:A --> </elem>
<elem />
示例2:
<elem> <!-- some content according to ex:A --> </elem>
<elem />
<elem> <!-- some content according to ex:A --> </elem>
<elem> <!-- some content according to ex:A --> </elem>
<elem />
如果我的意图不明确,请要求澄清。