I have this xsd:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns="http://myschema.com/schema"
targetNamespace="http://myschema.com/schema"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="aType" mixed="true">
<xs:group ref="aElements" minOccurs="0" maxOccurs="unbounded"/>
</xs:complexType>
<xs:group name="aElements">
<xs:choice>
<xs:element name="a" type="aType"/>
</xs:choice>
</xs:group>
<xs:element name="b">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:group ref="aElements"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
and I try to validate this xml document against it:
<?xml version="1.0" encoding="utf-8" ?>
<b xmlns="http://myschema.com/schema">
<a/>
</b>
However, Visual Studio 2008's xml validator complains about the <a> element:
The element 'b' in namespace 'http://myschema.com/schema' has invalid child element 'a' in namespace 'http://myschema.com/schema'. List of possible elements expected: 'a'.
What is the problem?
Edit: Oops, when dumbing down the example I caused forgot to make the element optional inside the element, causing infinite recursion. The problem is still there with this mod, though.
ANSWER: The answer was that the xs:schema tag should include the elementFormDefault="qualified" attribute.