Hi All,
I have the problem on validate the unique value of the element. Is always pass through although there is a duplicate value on the reference name.
Can someone help me on this? Thanks a lot.
Here is the code:
XML
<?xml version="1.0" encoding="UTF-8"?>
<dl xmlns="http://www.abc.com/schema/dl"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.abc.com/schema/dl
http://www.abc.com/schema/dl/dl.xsd">
<references>
<reference name="
abc" value="123"/>
<reference name="
abc" value="235" />
</references>
</dl>
dl.xsd
<?xml version="1.0"?>
<xs:schema xmlns="http://www.abc.com/schema/dl"
targetNamespace="http://www.abc.com/schema/dl"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:element name="dl">
<xs:complexType>
<xs:sequence>
<xs:element name="references" type="references-Type" minOccurs="0" maxOccurs="1">
<xs:unique name="CheckUniqueReference">
<xs:selector xpath="reference"/>
<xs:field xpath="@name"/>
</xs:unique>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="references-Type">
<xs:sequence>
<xs:element name="reference" type="referenceType" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="referenceType">
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="value" type="xs:string" use="required"/>
</xs:complexType>
</xs:schema>