Can I use maxOccurs="0"
?
Example:
<xs:element name="person">
<xs:complexType>
<xs:sequence>
<xs:element name="full_name" type="xs:string"/>
<xs:element name="child_name" type="xs:string" maxOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
Do you have a better way for this?
答案 0 :(得分:2)
好吧,只要minOccurs="0"
,您就可以设置maxOccurs="0"
,但更常见的是,您只需省略该元素以防止它出现:
<xs:element name="person">
<xs:complexType>
<xs:sequence>
<xs:element name="full_name" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>