I need to solve the following problem.
//pseudo algorithm
If your n
values not too big and you're desperate you can make a content model that accounted for every possible combination, but that grows complex exponentially.
The best solution is to use a tool that supports XML Schema 1.1 (such as Xerces or Saxon), which relaxes restrictions on all
group occurrence values. From section G.1.3 of the spec:
Several of the constraints imposed by version 1.0 of this specification on all-groups have been relaxed:
a. Wildcards are now allowed in all groups.
b. The value of maxOccurs may now be greater than 1 on particles in an all group. The elements which match a particular particle need not be adjacent in the input.
c. all groups can now be extended by adding more members to them.
Failing that, the general XML Schema 1.0 solution is to specify a relaxed model in the schema (no limits on the element occurrences) and then enforce the constraints you care about in another layer, which might be custom code or XSLT, for instance.