- From: Xuejun Li (SH/RDC) <xuejun.li@ericsson.com>
- Date: Thu, 28 Aug 2003 16:38:06 +0800
- To: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
Hi 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:complexType> <xs:sequence> <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:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="user admin"/> <xs:enumeration value="service admin"/> </xs:restriction> </xs:simpleType> </xs:element> </xs:sequence> <xs:attribute name="uid" type="xs:string" use="required"/> </xs:complexType> <xs:unique name="RolesUniqueCreate"> <xs:selector xpath="."/> <xs:field xpath="cpm:roles"/> </xs:unique> </xs:element> </xs:schema> 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"> <uid>String</uid> <cn>String</cn> <sn>String</sn> <userPassword>String</userPassword> <roles>user admin</roles> <roles>service admin</roles> </CreateAdministratorAttributes> Am I using unique the wrong way? How do I achieve the functionality I want? Thanks //Li Xuejun
Received on Thursday, 28 August 2003 04:35:26 UTC