Jump to content
Sign in to follow this  

Setting unique element restriction

Recommended Posts

Here is my schema, what I'm unable to do is set unique restrictions on the title element.

<?xml version="1.0" encoding="ISO-8859-1"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">	<xs:element name="departments">		<xs:complexType>			<xs:sequence>				<xs:element ref="department" minOccurs="1" maxOccurs="unbounded"/>			</xs:sequence>		</xs:complexType>	</xs:element>	<xs:element name="department">		<xs:complexType>			<xs:sequence>				<xs:element ref="title" minOccurs="1" maxOccurs="1"/>				<xs:element ref="subdepartment" minOccurs="1" maxOccurs="unbounded"/>			</xs:sequence>		</xs:complexType>	</xs:element>	<xs:element name="title">		<xs:simpleType>			<xs:restriction base="xs:string"/>		</xs:simpleType>	</xs:element>	<xs:element name="subdepartment">		<xs:simpleType>			<xs:restriction base="xs:string"/>		</xs:simpleType>	</xs:element></xs:schema>

What I'm trying is this within the title element tag, XMLSpy accepts it as valid but the restriction does not work if I test duplicate titles in my XML.

<xs:unique name="testUnique">	<xs:selector xpath="department"/>	<xs:field xpath="title"/></xs:unique>

Please help!

Edited by tombliboo

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...