Looks like it is impossible.
I have a book here: XML Schema: The W3C's Object-Oriented Descriptions for XML, which is probably the best book about XML schemas I've ever read (though rather complicated and not perfect one).
Here's what I see in that book (p. 236):
Situations describing unordered groups of optional elements that have the same number of maximum occurrences can be described using
xs:choice
or substitution groups, but other content models (such as groups unordered elements with arbitrary and different maximum numbers of occurrences) cannot be described with W3C XML Schema.
According to this, it looks like your A
element (that must occur exactly once) spoils everything!
I believe the reason of that limitation is the following:
You want to avoid exponential permutations, right? But if such content models were allowed to describe in a simple way, it would take an exponential algorithm to validate XML against them!
I think, W3C just wanted to avoid such problems outright by forcing schema designers to avoid arbitrary content models.