W3C home > Mailing lists > Public > xmlschema-dev@w3.org > October 2001

Re: Illegal use of unique? I need it. Microsoft supports it. Alternatives?

From: Jeni Tennison <jeni@jenitennison.com>
Date: Fri, 12 Oct 2001 18:28:33 +0100
Message-ID: <8323648564.20011012182833@jenitennison.com>
To: "Gary Robertson" <gazinyork@hotmail.com>
CC: xmlschema-dev@w3.org
Hi Gary,

> Yes, sorry, the information that I did not convey was that I wanted
> inheritance _and_ identity constraints: I wanted to have both an
> ObjectType (from which to inherit other types/elements) and a global
> Object element (of type ObjectType) to attach my unique construct to
> (and reference at various points within my root element).

I might be missing something, but if that's what you want, why don't
do you do it? There's nothing to stop you having a global element
declaration that uses a named complex type definition (defined at the
top level of the schema).

<xs:complexType name="ObjectType">
    <xs:extension base="AbstractMooDElementType">
        <xs:element ref="Object" minOccurs="0" maxOccurs="unbounded" />
        <xs:element name="State" type="StateType"
                    minOccurs="0" maxOccurs="unbounded" />

<xs:element name="Object" type="ObjectType">
  <xs:unique name="StateNamesUniqueWithinAnObject">
    <xs:selector xpath="State"/>
    <xs:field xpath="@name"/>

As long as all the Object elements that you want to be bound by the
uniqueness constraint have the same type (ObjectType) then this should
work fine, I think.



Jeni Tennison
Received on Friday, 12 October 2001 13:28:41 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:14:54 UTC