Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


XML_Schema: problem with

From: "Aray" <1@-.->
To: NULL
Date: 1/5/2007 4:36:00 PM

I googled for it for few houres, but didn't resolve it, any hints will be 
thinkfull.

I want to use the following XSD file to guarantee <element1> is 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" 
elementFormDefault="qualified">

<xs:element name="root" type="rootType">
 <xs:unique name="PK_element1">
  <xs:selector xpath="./element1"></xs:selector>
  <xs:field xpath="."></xs:field>
 </xs:unique>
</xs:element>

<xs:complexType name="rootType">
 <xs:choice>
  <xs:group ref="elementGroup" maxOccurs="unbounded" minOccurs="0" />
 </xs:choice>
</xs:complexType>

<xs:group name="elementGroup">
 <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:schemaLocation="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 <element1> has the 
same content.
    But it is valide
 -->
</root>



-- 
 




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent