复杂类型定义违反了唯一粒子属性

时间:2016-10-20 11:13:50

标签: xml xsd schema complextype

类型MyType的给定定义应该允许元素序列(A),(B),(C),(AB)和(AC)。在验证时,我得到了一个"独特的粒子归属违规"错误。我该如何解决这个问题?

<xs:complexType name="MyType">
  <xs:choice>
    <xs:element name="A" type="AType"/>
    <xs:sequence>
      <xs:element name="A" type="AType" minOccurs="0"/>
      <xs:choice>
        <xs:element name="B" type="BType"/>
        <xs:element name="C" type="CType"/>
      </xs:choice>
    </xs:sequence>
  </xs:choice>
</xs:complexType>

1 个答案:

答案 0 :(得分:0)

某些重构修复了唯一的粒子归因错误:

<xs:complexType name="MyType">
  <xs:choice>
     <xs:sequence>
       <xs:element name="A" type="AType"/>
       <xs:choice minOccurs="0">
         <xs:element name="B" type="BType"/>
         <xs:element name="C" type="CType"/>
       </xs:choice>
     </xs:sequence>
     <xs:element name="B" type="BType"/>
     <xs:element name="C" type="CType"/>
   </xs:choice>
</xs:complexType>
相关问题