I'm defining a user element with XSD. For this example, a user has a name, email and one or more nationalities. I've tried:
<xs:all>
<xs:element name="name" blabla />
<xs:element name="email" blabla />
<xs:element name="nationality" minOccurs="1" maxOccurs="unbounded" />
</xs:all>
However, that is illegal. Apparently elements inside an "All" can only occur one time (or not at all).
I could fix this by changing the All to a Sequence, but then people would have to enter the properties in the exact order, which I actually don't care about.
Is there a combination of these two available? Not according to http://www.w3schools.com/Schema/schema_complex_indicators.asp, but maybe it's hidden (or my inexperienced eyes don't see it).
By intuition, I also tried:
<xs:all>
<xs:element name="name" blabla />
<xs:element name="email" blabla />
<xs:sequence>
<xs:element name="nationality" minOccurs="1" maxOccurs="unbounded" />
</xs:sequence>
</xs:all>
But that's unfortunately invalid.
Here is the current, real, piece of XSD:
<!-- user -->
<xs:complexType name="user">
<xs:sequence>
<xs:element name="firstname" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="appendix" type="xs:string" minOccurs="0" maxOccurs="1" />
<xs:element name="lastname" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="address" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="zipcode" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="city" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="username" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="email" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="country" type="country" minOccurs="1" maxOccurs="1"/>
<xs:element name="nationality" type="xs:string" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…