Re: XML: How to require either or both of two child elements, but prevent both missing?
Le Samedi 22 Février 2003 23:58, vous avez écrit :
jrc> How about changing the model to 'choice' and requiring one but allowing two jrc> (or multiple) occurrences of optional elements? jrc> something like this maybe?
jrc> <xs:choice minOccurs="1" maxOccurs="2"> jrc> <xs:element name="A" minOccurs="0" maxOccurs="1"/> jrc> <xs:element name="B" minOccurs="0" maxOccurs="1"/> jrc> </xs:choice>
Dosn't it alllow the choice whithout A nor B for their minOccurs=0?
Just set minOccurs to 1 then. However, nothing prevent you from two A or two B then.
Substition group would do.
I guess you're thinking of making A and B member of Child substitution group, and requiring a sequence of 1 to 2 Child element in parent ? It won't solve the problem of two A or two B, as any other constraint considering child element separatly.
participants (1)
-
Guillaume Rousse