Identity Constraints

Is there a way to obtain typed reference using ID, IDREF, Key, KeyRef? For
example, could I define a fruit salad to consist of fruitTypes or references
to elements of type fruitType.

In other words, if I had the following elements,
	<xs:element name="FruitSalad">
		<xs:complexType>
			<xs:sequence maxOccurs="unbounded">
				??
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:element name="fruit" type="fruitType" abstract="true"/>
	<xs:complexType name="fruitType">
		<!-- The user should pick either "name" or "ref" but not both....
			how can I capture this? -->
		<xs:attribute name="name" type="xs:QName"/>
		<xs:attribute name="ref" type="xs:QName"/>
		<xs:attribute name="color" type="xs:string"/>
		<xs:attribute name="canEatSkin" type="xs:boolean"/>
	</xs:complexType>
	<xs:element name="apple" substitutionGroup="fruit">
		<xs:complexType>
			<xs:complexContent>
				<xs:extension base="fruitType">
					<xs:attribute name="canEatSkin" fixed="true"/>
					<xs:attribute name="makesGoodPie" type="xs:boolean"/>
				</xs:extension>
			</xs:complexContent>
		</xs:complexType>
	</xs:element>
	<xs:element name="banana" substitutionGroup="fruit">
		<xs:complexType>
			<xs:complexContent>
				<xs:extension base="fruitType">
					<xs:attribute name="color" fixed="yellow"/>
					<xs:attribute name="canEatSkin" fixed="false"/>
				</xs:extension>
			</xs:complexContent>
		</xs:complexType>
	</xs:element>

I would like the instance document to look like:
	<FruitSalad>
		<apple ref="Granny"/>
		<apple canEatSkin="true" color="yellow" makesGoodPie="false"/>
		<banana canEatSkin="false"/>
	</FruitSalad>
	<apple name="Granny" color="green" canEatSkin="true" makesGoodPie="true"/>
	<apple name="SnowWhite's" color="red" canEatSkin="false"
makesGoodPie="false"/>

Thank you!

Received on Monday, 22 October 2001 11:05:14 UTC