I am trying to define xsd for the below xml:
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
<to>Tove</to>
</note>
I have defined below xsd for above.
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="note">
<xs:complexType>
<xs:choice maxOccurs="unbounded" minOccurs="0">
<xs:element type="xs:string" name="to"/>
<xs:element type="xs:string" name="from"/>
<xs:element type="xs:string" name="heading"/>
<xs:element type="xs:string" name="body"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
But the tricky part here is how can i define only "to" element repeated any number of times and in any order but "from", "heading", "body" repeated only once.How to keep this kind of restriction in the xsd.