I have a schema which looks like:
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Contacts">
<xs:complexType>
<xs:sequence>
<xs:element name="Contact" maxOccurs="unbounded">
<xs:complexType>
<xs:all>
<xs:element name="Id">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Name">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:pattern
value="[a-z\-_]+"
/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Mobile">
<xs:simpleType>
<xs:restriction base="xs:Integer">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
Now the requirement is that we can add multiple Mobile phone numbers for each contact i.e. a xml as follows:
<?xml version="1.0" encoding="UTF-8"?>
<Contacts>
<Contact>
<Id>1</Id>
<Name>Rebecca</Name>
<Mobile>1234</Mobile>
<Mobile>4567</Mobile>
</Contact>
</Contacts>
Because the Contact element in xsd uses xs:all, it doesn't allow adding multiple Mobile elements. Is there a way to allow multiple Mobile elements but only single occurrence of rest of the elements? Name & Id should have one occurrence only in xml.