I have an XSD of this form:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org/example"
xmlns:tns="http://www.example.org/example" elementFormDefault="qualified">
<complexType name="bType">
</complexType>
<complexType name="aType">
<choice maxOccurs="unbounded">
<element name="a" type="tns:aType" />
<element name="b" type="tns:bType" />
</choice>
</complexType>
<element name="topelement">
<complexType>
<sequence>
<element name="a" type="tns:aType" maxOccurs="1" />
</sequence>
</complexType>
</element>
</schema>
And an XML file that I expect to match it, e.g:
<?xml version="1.0" encoding="UTF-8"?>
<topelement xmlns="http://www.example.org/example"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org/example example.xsd ">
<a> <!-- Error on this line. -->
<a/>
<b/>
<b/>
<a/>
</a>
</topelement>
Unfortunately the XSD says that this is not valid with the following error:
cvc-complex-type.2.4.b: The content of element 'a' is not complete. One of '{"http://www.example.org/example":a, "http://www.example.org/example":b}' is expected. example.xml line 5
As far as I can tell, I've done everything I need to do for the tag to be complete. I've filled it with an unbounded choice of 'a' and 'b' tags. Can anyone see what's gone wrong?
To clarify, I want there to be only one 'a' tag under topelement, and underneath that, a mix of 'a' and 'b' tags.