I know about this related question and I understand that my question contradicts that answer, but the following XML file validates perfectly against the following XMLSchema
my XML data:
<?xml version="1.0" encoding="utf-8"?>
<myElements>
<el1>bla</el1>
<el1>bla</el1>
<el1>blabla</el1>
<el2>bgt</el2>
<el2>pel</el2>
<el3>sdf</el3>
</myElements>
my XMLSchema:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="myElements">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="el1" />
<xs:element name="el2" />
<xs:element name="el3" />
<xs:element name="el4" />
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
W3schools and other sources say that:
XML Schema choice element allows only one of the elements contained in the declaration to be present within the containing element.
In my opinion this means that my XML data should accept exactly only one of these:
- 0 to any el1
- 0 to any el2
- 0 to any el3
- 0 to any el4
But if you try to validate my xml data to my xmlschema, it is valid, and I do not understand why.
Do I completely misunderstand the documentation?
Is the validator I am using to lax and non-standard? If yes, what would be a good validator and why would anyone use a choice in a situation like I described? (Yes, I did encounter this)
0
ton
times, allow a single element of these choices... In other words, since the choice occurrence is boundless, you can have one element from the choice any number of times. – Humperdinck