How can I enforce to chose at lease one, but no repeat?
The following syntax allows any c element to repeat up to 3 times.
<choice minOccurs="1" maxOccurs="3">
<element name="c1" type="string" />
<element name="c2" type="string" />
<element name="c3" type="string" />
</choice>
thnx
steve
Loose the
maxOccurs="3"and what you got is “choose at least one”, no repeat.For particles, the default is
minOccurs="1"; a mandatory choice, where each option particle is itself mandatory, is your answer.UPDATE: Based on your comment, if what you’re looking is for any ordered combination of the particles you’ve described, this is the best you can get with XSD spec.
This is messy already; if you’re looking for a greater number of particles or any unordered combination, then I would change the model to something like this (these are XSD 1.0 limitations in action – it all has to do with limitations in the XPath syntax you can use for selectors/fields).
A sample XML would like this:
or this:
Basically you’re keying in on some component that makes your element unique, that is part of the data as opposed to a tag name. Again, messy, but as an exercise, it may give you an idea.