I have an XML document like:
<Root>
<Bravo />
<Alpha />
<Charlie />
<Charlie />
<Delta />
<Foxtrot />
<Charlie />
</Root>
节点的顺序并不重要。每个节点可以出现零次或一次,除了Charlie节点。Charlie节点可以出现零次、一次或任意多次。在XSD中表达这一点的直接方式是:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="Root">
<xsd:complexType>
<xsd:all>
<xsd:element name="Alpha" minOccurs="0" maxOccurs="1" />
<xsd:element name="Bravo" minOccurs="0" maxOccurs="1" />
<xsd:element name="Charlie" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="Delta" minOccurs="0" maxOccurs="1" />
<xsd:element name="Echo" minOccurs="0" maxOccurs="1" />
<xsd:element name="Foxtrot" minOccurs="0" maxOccurs="1" />
</xsd:all>
</xsd:complexType>
</xsd:element>
</xsd:schema>
但这样做是行不通的,因为xsd:all不允许maxOccurs大于1。既然我不能使用xsd:all,那我应该使用什么?