thinkfull.
I want to use the following XSD file to guarantee <element1is unique, but
it doesn't work.
The following is my XSD file and XML file:
----------- test.xsd ----------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.aray.com" targetNamespace ="http://www.aray.com"
elementFormDefa ult="qualified" >
<xs:element name="root" type="rootType" >
<xs:unique name="PK_elemen t1">
<xs:selector xpath="./element1"></xs:selector>
<xs:field xpath="."></xs:field>
</xs:unique>
</xs:element>
<xs:complexTy pe name="rootType" >
<xs:choice>
<xs:group ref="elementGro up" maxOccurs="unbo unded" minOccurs="0" />
</xs:choice>
</xs:complexType>
<xs:group name="elementGr oup">
<xs:choice>
<xs:element name="element1" type="xs:string " />
<xs:element name="element2" type="xs:string " />
</xs:choice>
</xs:group>
</xs:schema>
----------- test.xml ----------------
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="http://www.aray.com"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="http://www.aray.com test.xsd"
><element1>1</element1>
<element2>1</element2>
<element1>1</element1>
<!--
I expect this xml file is not valide, because the two <element1has the
same content.
But it is valide
-->
</root>
--