See XML Schema Part 0: Primer Second Edition , Section 2.2.1 Appearance Restrictions .
It says:
Typically, an item should appear when the value of minOccurs is 1 or more. The maximum number of times an item can appear is determined by the value of the maxOccurs attribute in its declaration. This value can be a positive integer, such as 41, or an unlimited member to indicate that the maximum number of occurrences does not exist. The default value for the minOccurs and maxOccurs attributes is 1.
Since the attribute value cannot be inferred from other contents of the schema in the XML schema, what you want to achieve is not possible (using the XML schema).
(I don't know if Relax NG can , but you can find out if it supports such content-dependent definitions.)
source share