java – XML模式可以在单个complexType中有多个选项吗?
发布时间:2020-12-14 05:51:36 所属栏目:Java 来源:网络整理
导读:是否可以在 XML模式中执行此类操作? xsd:complexType name="ItemsType" xsd:choice minOccurs="0" maxOccurs="unbounded" xsd:element ref="shirt"/ xsd:element ref="hat"/ xsd:element ref="umbrella"/ /xsd:choice xsd:choice minOccurs="1" maxOccurs="
是否可以在
XML模式中执行此类操作?
<xsd:complexType name="ItemsType"> <xsd:choice minOccurs="0" maxOccurs="unbounded"> <xsd:element ref="shirt"/> <xsd:element ref="hat"/> <xsd:element ref="umbrella"/> </xsd:choice> <xsd:choice minOccurs="1" maxOccurs="3"> <xsd:element ref="apple"/> <xsd:element ref="banana"/> <xsd:element ref="strawberry"/> </xsd:choice> </xsd:complexType> 这显然是无效的.我想要的是可以有0或更多的第一选择.例如.可能有一个衬衫元素和一个帽子元素,或者根本没有衣服元素(因为minOccurs =“0”),然后是至少1个水果元素(我想要它,所以必须至少有一个,因为的minOccurs = “1”). 有办法吗? 谢谢你的帮助. 解决方法
< XSD:的complexType>期望只有一个子元素.将您的两个选项包含在单个< xsd:sequence>中.
例 <xsd:complexType name="ItemsType"> <xsd:sequence> <xsd:choice minOccurs="0" maxOccurs="unbounded"> ... clothes ... </xsd:choice> <xsd:choice minOccurs="1" maxOccurs="3"> ... fruits ... </xsd:choice> </xsd:sequence> </xsd:complexType> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |