I am learning xml and schema.I want a schema where Telephone element value have to be unique. I try with unique but can't understand how it's work. Sorry for this silly question but i am learning.
xml
<?xml version="1.0" encoding="utf-8" ?>
<Company xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Employee>
<Name>ABC</Name>
<Telephone>9998887770</Telephone>
</Employee>
<Employee>
<Name>DEF</Name>
<Telephone>9998887770</Telephone>
</Employee>
<Employee>
<Name>GHI</Name>
<Telephone>1234567890</Telephone>
</Employee>
</Company>
schema
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="EmployeeSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Name"/>
<xs:element name="Telephone" />
<xs:simpleType name="string32">
<xs:restriction base="xs:token">
<xs:maxLength value="32"/>
</xs:restriction>
<xs:element name="Company">
<xs:complexType>
<xs:sequence>
<xs:element ref="Employee" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<!--Here i try to implement unique--->
<xs:unique name="Company">
<xs:selector xpath="Telephone"/>
<xs:field xpath="Telephone"/>
</xs:unique>
</xs:element>
<xs:element name="Employee">
<xs:complexType>
<xs:sequence>
<xs:element ref="Name"/>
<xs:element ref="Telephone"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>