W3C home > Mailing lists > Public > xmlschema-dev@w3.org > August 2003

The use of unique

From: Xuejun Li (SH/RDC) <xuejun.li@ericsson.com>
Date: Thu, 28 Aug 2003 16:38:06 +0800
Message-ID: <55CF389EF371D511B67C00508BADDC2F02892AA4@ecnshnt514.itc.ericsson.se>
To: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>

I met some strange problem when I tried to use unique.
I made such a schema:
<xs:schema targetNamespace="http://schemas.ericsson.com/snf/cpm1.0/" xmlns:cpm="http://schemas.ericsson.com/snf/cpm1.0/" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
	<xs:element name="CreateAdministratorAttributes">
				<xs:element name="uid" type="xs:string"/>
				<xs:element name="cn" type="xs:string" maxOccurs="unbounded"/>
				<xs:element name="sn" type="xs:string" maxOccurs="unbounded"/>
				<xs:element name="userPassword" type="xs:string"/>
				<xs:element name="roles" minOccurs="0" maxOccurs="2">
						<xs:restriction base="xs:string">
							<xs:enumeration value="user admin"/>
							<xs:enumeration value="service admin"/>
			<xs:attribute name="uid" type="xs:string" use="required"/>
		<xs:unique name="RolesUniqueCreate">
			<xs:selector xpath="."/>
			<xs:field xpath="cpm:roles"/>
What I intend to limit with unique is there should not be two roles that are equal, but there can be maximum 2 different roles. But when I tried to validate the following XML, I got an error saying "The fields XPath selector of the unique identity constraint 'RolesUniqueCreate' must evaluate to exactly 0 or 1 nodes" (from XMLSpy) or "Field matches more than one value within the scope of its selector; fields must match unique values" (from Xerces).
<CreateAdministratorAttributes xmlns="http://schemas.ericsson.com/snf/cpm1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.ericsson.com/snf/cpm1.0/ UniqueTest.xsd" uid="String">
	<roles>user admin</roles>
	<roles>service admin</roles>
Am I using unique the wrong way? How do I achieve the functionality I want?
//Li Xuejun
Received on Thursday, 28 August 2003 04:35:26 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:12 UTC