Re: XML: How to require either or both of two child elements, but prevent both missing?
How in XML-schema do you make sure that of two possible child elements, either or both, but not neither are present?
How about changing the model to 'choice' and requiring one but allowing two (or multiple) occurrences of optional elements?
something like this maybe?
<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="Parent"> xs:complexType <xs:choice minOccurs="1" maxOccurs="2"> <xs:element name="A" minOccurs="0" maxOccurs="1"/> <xs:element name="B" minOccurs="0" maxOccurs="1"/> </xs:choice> </xs:complexType> </xs:element> </xs:schema>
~ Jim Croft ~ jrc@anbg.gov.au ~ 02-62465500 ~ www.anbg.gov.au/jrc/ ~
participants (1)
-
Jim Croft