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:complexContent>
    <xs:extension base="AbstractMooDElementType">
      <xs:sequence>
        <xs:element ref="Object" minOccurs="0" maxOccurs="unbounded" />
        <xs:element name="State" type="StateType"
                    minOccurs="0" maxOccurs="unbounded" />
      </xs:sequence>
    </xs:extension>
  </xs:complexContent>
</xs:complexType>

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

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.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Friday, 12 October 2001 13:28:41 GMT

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