Hi All,
I have the following XSD where my "number" is having unique constarint
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element ref="number"/>
<xs:element ref="digit"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="number" type="xs:integer">
<xs:unique name="numberUnique">
<xs:selector xpath="number"></xs:selector>
<xs:field xpath="."></xs:field>
</xs:unique>
</xs:element>
<xs:element name="digit" type="xs:integer"/>
</xs:schema>
My corresponding XML is like below
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="Unique.xsd">
<number> 2</number>
<digit>2</digit>
</root>
As i understand, since number has xsd:unique constraint, the value should be unique in its parent scope. But in my above XML, the values for "number" and "digit" are same, which is 2. When i validate the XML with XSD, i am not seeing any error.
SO i believe my understanding is not correct. Can someone explain how xsd:unique works?
Thanks a lot,
Karuna