The XSD sequence shows how ambiguous

I have an XSD that was transformed from a RELAX NG schema with several errors that I am trying to fix. Big problem I have with the following

  <xs:element name="list">
    <xs:complexType>
      <xs:sequence>
        <xs:choice>
          <xs:sequence>
            <xs:element minOccurs="0" ref="preamble"/>
            <xs:element minOccurs="0" ref="title"/>
          </xs:sequence>
          <xs:sequence>
            <xs:element minOccurs="0" ref="title"/>
            <xs:element minOccurs="0" ref="preamble"/>
          </xs:sequence>
        </xs:choice>
        <xs:group maxOccurs="unbounded" ref="block-selectionListItem"/>
      </xs:sequence>
      <xs:attributeGroup ref="attlist-selectionList"/>
    </xs:complexType>
  </xs:element>

      

As you can see, the xs: select block allows you to choose between two xs: sequence blocks. Seems to make sense, except that Visual Studio gives the following warning in the second item <xs:element minOccurs="0" ref="title/>

, which discards everything:

The multiple definition of the title element means that the content model becomes ambiguous. The content model should be formed in such a way that during the verification of the sequence of elements of information of an element, a particle contained directly, indirectly or implicitly in which, in order to try to verify each element in the sequence, in turn, can be uniquely identified without examining the content or attributes of this element and without any information about the elements in the rest of the sequence.

Because you can only choose one, I don't see how ambiguous it is. Any help would be greatly appreciated!

Answer:

As stated in the answer below, I left out all possibilities. So here's what I had to do:

  <xs:element name="list">
    <xs:complexType>
      <xs:sequence>
        <xs:group minOccurs ="0" maxOccurs="1" ref ="list-titlePreambleChoice"/>
        <xs:group maxOccurs="unbounded" ref="block-basicListItem"/>
      </xs:sequence>
      <xs:attributeGroup ref="attlist-basicList"/>
    </xs:complexType>
  </xs:element>

      

                                                                                                                     

This solved all my problems. Thank!

+2


source to share


1 answer


It is ambiguous because of minOccurs="0"

. If the validator finds an item preamble

, is it the first item of the first choice, or is it the second item of the second choice and the item is title

missing?



+1


source







All Articles