- From: Gary Robertson <gazinyork@hotmail.com>
- Date: Wed, 10 Oct 2001 09:01:11 -0400 (EDT)
- To: <xmlschema-dev@w3.org>
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 UTC