Jump to content

Setting unique element restriction


tombliboo

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!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...