V
Victor
Hi, I am pulling my hair out on this one.
I have written an XML schema to ensure that a person name occurs only
once (ie it is unique). The XML has the name Christophe once, and
Victor twice, but it appears valid allowing Victor twice. How come, I
cannot see my bug? I know the schema is validating the XML as if I
enter 4 names (and not 3 or less), it is showing up invalid.
Thank you for thinking on this.
Victor
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="addressBook">
<xs:complexType>
<xs:sequence>
<xs:element name="personName" maxOccurs="3">
<xs:unique name="dummy">
<xs:selector xpath="addressBook/personName"/>
<xs:field xpath="."/>
</xs:unique>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<?xml version="1.0" encoding="UTF-8"?>
<addressBook xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="C:\Documents and
Settings\VCuklin\Desktop\XMLSPYTest\test.xsd">
<personName>Victor</personName>
<personName>Christophe</personName>
<personName>Victor</personName>
</addressBook>
I have written an XML schema to ensure that a person name occurs only
once (ie it is unique). The XML has the name Christophe once, and
Victor twice, but it appears valid allowing Victor twice. How come, I
cannot see my bug? I know the schema is validating the XML as if I
enter 4 names (and not 3 or less), it is showing up invalid.
Thank you for thinking on this.
Victor
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="addressBook">
<xs:complexType>
<xs:sequence>
<xs:element name="personName" maxOccurs="3">
<xs:unique name="dummy">
<xs:selector xpath="addressBook/personName"/>
<xs:field xpath="."/>
</xs:unique>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<?xml version="1.0" encoding="UTF-8"?>
<addressBook xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="C:\Documents and
Settings\VCuklin\Desktop\XMLSPYTest\test.xsd">
<personName>Victor</personName>
<personName>Christophe</personName>
<personName>Victor</personName>
</addressBook>