I found various resources wherein it is said that you can have circular dependencies if it can be re-written as an XSD without circular dependency.
I have two files
schemaA.xsd
<xs:include schemaLocation="schemaB.xsd"/>
schemaB.xsd
<xs:include schemaLocation="schemaA.xsd"/>
This is clearly a circular dependency and I am unable to understand how this is resolved. However, few online validators say it is valid and few say it is not. If it is, please help me understand how it is compiled. The library that I want to use is unable to compile it.
It's valid.
I tried to persuade the editors of the spec to add clarification on this but they claimed it was perfectly clear. (As a spec editor myself, I've slowly learned to accept that if a reader says something is unclear, then by definition, it is.)
It's basically permitted because there's no rule that says it isn't.
In XSD 1.1 the spec says:
If a ·schema document· D1 contains one or more elements, then schema(D1) contains not only immed(D1)
but also all the components of schema(D2), for each ·schema document· D2 identified by an <include>
element child of D1.
That's a recursive definition, and as a programmer you might think "what happens if it's a circular definition". The response I got from the editors was: you're not supposed to be thinking like a programmer; or if you are, then dealing with cycles is your problem, not ours. In mathematical graph theory the transitive closure of a relation is well-defined even if the relation is not acyclic; evaluating the transitive closure without going into a loop is an implementation problem, not a specification problem.
So in short, what the spec says is that the schema contains everything reachable via one or more xs:include
directives, and if those directives take you round in circles, the processor just has to deal with it.
How you solve your problem is another question. As always, when faced with a buggy product, your choices are:
Raise a bug report and wait for a resolution
Abandon use of that product and switch to an alternative
Avoid use of the feature that doesn't work.