1

XSD Code: getting error- the content model of complex type definition ' anonymous ' is ambiguous

<xs:element name="data">
            <xs:complexType>
                <xs:choice>
                    <xs:choice minOccurs="0" maxOccurs="unbounded">
                        <xs:element name="A"/>
                        <xs:element name="B"/>
                        <xs:element name="C"/>
                        <xs:element name="D"/>
                        <xs:element name="EE"/>
                    </xs:choice>
                    <xs:choice minOccurs="0" maxOccurs="unbounded">
                        <xs:element name="A"/>
                        <xs:element name="B"/>
                        <xs:element name="C"/>
                        <xs:element name="D"/>
                        <xs:element name="FF"/>
                    </xs:choice>
                </xs:choice>
            </xs:complexType>
        </xs:element>
Lavekush Agrawal
  • 6,040
  • 7
  • 52
  • 85
  • This is expected behaviour. You can't have two identical element declarations in the same context. What do you expect to validate? Please add more detail so we can suggest a better solution. – helderdarocha Apr 18 '14 at 13:38
  • 1
    Appears to be a duplicate of http://stackoverflow.com/questions/23149300/nested-choice-element-in-xml-schema – C. M. Sperberg-McQueen Apr 18 '14 at 15:33

1 Answers1

1

<xs:choice> selects one among many. You have nested choices. The parser complains that there is ambiguity because you have repeating elements declared in the neste choices, violating the Unique Particle Attribution constraint.

Example: If the first nested choice chooses A, and the second one also chooses A, you will have this illegal situation in your outer choice:

<xs:choice>
    <xs:element name="A"/>
    <xs:element name="A"/>
</xs:choice>

You can have one nested choice and accept multiple A elements, but not two identical element declarations.

Your code will work if you replace the outer choice for a sequence.

If you add more detail to your question this answer can be improved to show you a better alternative.

helderdarocha
  • 23,209
  • 4
  • 50
  • 65
  • can you please review this question http://stackoverflow.com/questions/23149300/nested-choice-element-in-xml-schema i want to solution of this question please help me. – Lavekush Agrawal Apr 18 '14 at 13:54
  • See the explanation in that page you referred above in the answer by @C-M-Sperberg-McQueen. – helderdarocha Apr 18 '14 at 15:45