任何已定义类型的组件集合的XML架构
我已经定义了类型任何已定义类型的组件集合的XML架构,xml,xsd,xsd-validation,xml-validation,Xml,Xsd,Xsd Validation,Xml Validation,我已经定义了类型inputExtType和inputEmailType的组件(它们的定义在这里并不重要)。我需要以任何顺序(例如:文本、电子邮件、文本、文本)收集任何数量的inputText和/或inputEmail组件。我试过: <xs:complexType name="componentsType"> <xs:choice> <xs:element name="inputText" type="inputTextType" maxOcc
inputExtType
和inputEmailType
的组件(它们的定义在这里并不重要)。我需要以任何顺序(例如:文本、电子邮件、文本、文本)收集任何数量的inputText和/或inputEmail组件。我试过:
<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>
它起作用了,但我无法定义文本、电子邮件、文本、文本,只能先定义所有文本,然后定义所有电子邮件。将出现约束上移到
xs:choice
:
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="inputText" type="inputTextType"/>
<xs:element name="inputEmail" type="inputEmailType"/>
</xs:choice>
<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>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="inputText" type="inputTextType"/>
<xs:element name="inputEmail" type="inputEmailType"/>
</xs:choice>