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

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

From: Gary Robertson <gazinyork@hotmail.com>
Date: Wed, 10 Oct 2001 09:01:11 -0400 (EDT)
To: <xmlschema-dev@w3.org>
Message-ID: <OE25aD8z9tTx7e4Vksa0000ab2f@hotmail.com>
I want to have a type "Object" that contains multiple "State" elements.
I want the state names to be unique within each object instance but
not globally. This is an example of a very common real world
requirement. Praise to Microsoft's MSXML4 beta 2 for letting me
achieve my aims like so:

<xs:complexType name="ObjectType">
  <xs:complexContent>
  <xs:extension base="AbstractElementType">
    <xs:sequence>
      <xs:element name="State" type="StateType" minOccurs="0"
maxOccurs="unbounded">
      <xs:unique name="StateNamesUniqueWithinAnObject">
      <xs:selector xpath="../State"/>
      <xs:field xpath="@name"/>
      </xs:unique>
      </xs:element>
    </xs:sequence>
  </xs:extension>
  </xs:complexContent>
</xs:complexType>

However, note use of parent node syntax (..) in the selector xpath.
Is this illegal? If so, how do I acheive my aim legally? I intend to
declare object instances at multiple points and levels in my schema
and it would be extremely onerous and poor software engineering
practice to have to attach a unique to every instance.

--
Gaz
Received on Wednesday, 10 October 2001 10:27:59 GMT

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