Hi,
I am trying to make an integrity constraint but it doesn't seem to be working. The constraint should make the element person_id a key but the instance has 2 persons with the same id. Validation says it's ok

(NOTE I'm using XML Spy. I have tested or made on purpose and got a bad validation so I know the validation works.

?? Any Ideas ???

The schema and xml instance are below.


---------SCEMA------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:complexType>
<xs:sequence>
<xs:element name="person" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="person_id" type="xs:integer"/>
<xs:element name="first_nm" type="xs:string"/>
<xs:element name="last_nm" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:key name="personKey">
<xs:selector xpath="."/>
<xs:field xpath="person_id"/>
</xs:key>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

-----------------------XML DOC ---------------
<?xml version="1.0" encoding="UTF-8"?>
<person_list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="D:\WebDev\HTML\XML\integrity_constraint\persons.xsd">
<person>
<person_id>22</person_id>
<first_nm>Person</first_nm>
<last_nm>One</last_nm>
</person>
<person>
<person_id>22</person_id>
<first_nm>Person</first_nm>
<last_nm>Two</last_nm>
</person>
</person_list>