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

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 UTC