Mega Code Archive

 
Categories / XML Tutorial / XML Schema
 

Require Both Elements or None

File: Schema.xsd <?xml version = "1.0" ?> <xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema">         <xs:element name="Book">        <xs:complexType>           <xs:sequence minOccurs = "0" maxOccurs = "1">                 <xs:element name="Title" type="xs:string" />                 <xs:element name="Author" type="xs:string"  />           </xs:sequence>        </xs:complexType>     </xs:element>     </xs:schema> So the following two examples would be allowed: <Book></Book> <Book>    <Title>XML</Title>    <Author>author</Author> </Book> But the third is invalid because it only contains one of the child elements: <Book>    <Title>Professional XML Schema</Title> </Book>