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

Restricting two attributes to be unequal

From: Brett Randall <brett_s_r@hotmail.com>
Date: Sat, 27 Sep 2003 04:07:12 +0000
To: xmlschema-dev@w3.org
Message-ID: <BAY2-F168IaHtF8zAOX00028242@hotmail.com>

Hi all,

I am wondering if the following is possible in XML Schema, and if so, how it 
can be done.  I have an element that is a complexType with two integer 
attributes "from" and "to" :

<xs:element name="myelement" maxOccurs="unbounded">
	<xs:complexType>

		<xs:sequence>
			<-- snip -->
		</xs:sequence>

		<xs:attribute name="from" use="required">
			<xs:simpleType>
				<xs:restriction base="xs:integer"/>
			</xs:simpleType>
		</xs:attribute>

		<xs:attribute name="to" use="required">
			<xs:simpleType>
				<xs:restriction base="xs:integer"/>
			</xs:simpleType>
		</xs:attribute>

	</xs:complexType>
</xs:element>

What I would like to do firstly is to prevent attribute values "from" and 
"to" from being equal in documents based on this schema, forcing them to be 
unequal.  A unique or key won't do as I want to force uniqueness over two 
attributes.

Out of interest, if I can force them to be unequal, can I also force 
from<to?

I'm guessing I need some sort of attributeGroup?

Any help/guidance appreciated.

Regards,
Brett

_________________________________________________________________
ninemsn Premium transforms your e-mail with colours, photos and animated 
text. Click here  http://ninemsn.com.au/premium/landing.asp
Received on Saturday, 27 September 2003 00:08:45 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:39 GMT