次の XSD コードがあります。
<xsd:complexType name="questions">
<xsd:sequence>
<xsd:element name="location" type="location"/>
<xsd:element name="multipleChoiceInput" type="multipleChoiceInput" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="textInput" type="textInput" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="pictureInput" type="pictureInput" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
ここでの問題は、要素の場所、multipleChoiceInput などは、宣言されているのと同じ順序で表示する必要があることです。私はこれが起こってほしくありません。検証プロセスでは、シーケンスが関連してはなりません。どうすればこれを達成できますか?
私が試した別の可能性は次のとおりです。
<xsd:complexType name="questions">
<xsd:choice maxOccurs="unbounded">
<xsd:element name="location" type="location"/>
<xsd:element name="multipleChoiceInput" type="multipleChoiceInput" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="textInput" type="textInput" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="pictureInput" type="pictureInput" minOccurs="0" maxOccurs="1"/>
</xsd:choice>
</xsd:complexType>
この例では、シーケンスはもはや重要ではなく、必要な数の要素を使用できます (「すべて」ではできないこと)。しかし、minOccurs と maxOccurs にはまだ問題があります。この例では、できるだけ多くの「pictureInput」を使用できますが、0 または 1 のいずれかを使用したいという制約があります。
助けてくれてありがとう!