XSD选择可以为空吗?(Can XSD choice be empty?)

我已经阅读了XSD规范,但我仍然感到困惑。 在XSD中有空的选择吗? 我的意思是,如果没有声明属性的简单选择,必须有元素“a”或元素“b”,或者它是否为空?

<xs:complexType name="ChoiceType"> <xs:choice> <xs:element name="a" type="type_a"/> <xs:element name="b" type="type_b"/> </xs:choice> </xs:complexType>

I've read the XSD specification but I'm still confused. Is an empty choice valid in XSD? I mean, with a simple choice with no attributes declared, is mandatory to have either element "a" or element "b", or can it be empty?

<xs:complexType name="ChoiceType"> <xs:choice> <xs:element name="a" type="type_a"/> <xs:element name="b" type="type_b"/> </xs:choice> </xs:complexType>

最满意答案

在这种情况下可能为空

<xs:complexType name="ChoiceType"> <xs:choice minOccurs="0"> <xs:element name="a" type="type_a"/> <xs:element name="b" type="type_b"/> </xs:choice> </xs:complexType>

无论如何看到这个问题

Could be empty in this scenario

<xs:complexType name="ChoiceType"> <xs:choice minOccurs="0"> <xs:element name="a" type="type_a"/> <xs:element name="b" type="type_b"/> </xs:choice> </xs:complexType>

anyway see this question

更多推荐

XSD,choice,电脑培训,计算机培训,IT培训"/> <meta name="description"