2016-11-17 7 views
1

タイプinputTextTypeinputEmailTypeのコンポーネントを定義しました(ここでの定義は重要ではありません)。どのような順番(例:text、email、text、text)であれ、数字のinputTextおよび/またはinputEmailのコレクションをcomponentsにする必要があります。私が試した:定義済みのタイプのコンポーネントを収集するためのXMLスキーマ

<xs:complexType name="componentsType"> 
    <xs:choice> 
     <xs:element name="inputText" type="inputTextType" maxOccurs="unbounded" minOccurs="0"/> 
     <xs:element name="inputEmail" type="inputEmailType" maxOccurs="unbounded" minOccurs="0"/> 
    </xs:choice> 
</xs:complexType> 

が、その後、検証XML

<components> 
    <inputText> 
     <label>label 1</label> 
     <name>as</name> 
    </inputText> 
    <inputText> 
     <label>label 2</label> 
     <name>ghyyy6</name> 
    </inputText> 
    <inputEmail> 
     <label>drg</label> 
     <name>rgtght</name> 
    </inputEmail> 
</components> 

私はエラーcvc-complex-type.2.4.a: Invalid content was found starting with element 'inputEmail'. One of '{inputText}' is expected.を持っています。 XMLが正しい(私はそれが必要です)。 XSDの修正方法は? I上記のXMLについては

<xs:complexType name="componentsType"> 
    <xs:choice> 
     <xs:element name="inputText" type="inputTextType" maxOccurs="unbounded" minOccurs="0"/> 
     <xs:element name="inputEmail" type="inputEmailType" maxOccurs="unbounded" minOccurs="0"/> 
    </xs:choice> 
</xs:complexType> 

にXSDを変更し、それが働いていたが、その後、私は、テキスト、電子メール、テキスト、テキストが、その後最初のすべてのテキストおよびすべての電子メールを定義することはできませんよ。

答えて

1

xs:choiceまでの発生の制約を移動:

<xs:choice minOccurs="0" maxOccurs="unbounded"> 
    <xs:element name="inputText" type="inputTextType"/> 
    <xs:element name="inputEmail" type="inputEmailType"/> 
</xs:choice> 
関連する問題