Does the concept of Generalization (present in object language) exist in XML Schema ?
Here is a simple XML example of what i'd like to write :
<FruitBag>
<Apple color="red" radius="2"/>
<Orange color="orange" radius="2"/>
<Banana color="yellow" heigth="5"/>
</FuitBag>
And here is the kind of declaration i'd like to have :
a fruit :
<xs:complexType name="FruitType">
<xs:attribute name="color" type="xs:string" />
</xs:complexType>
an apple :
<xs:complexType name="AppleType">
<xs:complexContent>
<xs:extension base="FruitType">
<xs:attribute name="radius" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
a banana :
<xs:complexType name="BananaType">
<xs:complexContent>
<xs:extension base="FruitType">
<xs:attribute name="heigth" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
and for the FuitBag, i'd like to define it like a container of FruitType. It can contain Apple, and/or Banana, because Apple and Banana are FruitType.
But if i define it like this :
<xs:complexType name="FruitBag">
<xs:sequence>
<xs:element name="Fruit" type="FruitType maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
A valid XML would be :
<FruitBag>
<Fruit color="red" />
<Fruit color="orange" />
<Fruit color="yellow" />
</FuitBag>
And that's not what I want.
I don't want to define FruitBag like a container of Apple Banana, etc,
because I can have a lot of different fruits type, and if I define another kind of Fruit, i would have to add it to the declaration of my FruitBag.
So does this concept exist in XML schema ?
Or is there any way to do something like this ?
Thanks for the answers.
(Sorry if the question have allready been asked)
Here is a simple XML example of what i'd like to write :
<FruitBag>
<Apple color="red" radius="2"/>
<Orange color="orange" radius="2"/>
<Banana color="yellow" heigth="5"/>
</FuitBag>
And here is the kind of declaration i'd like to have :
a fruit :
<xs:complexType name="FruitType">
<xs:attribute name="color" type="xs:string" />
</xs:complexType>
an apple :
<xs:complexType name="AppleType">
<xs:complexContent>
<xs:extension base="FruitType">
<xs:attribute name="radius" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
a banana :
<xs:complexType name="BananaType">
<xs:complexContent>
<xs:extension base="FruitType">
<xs:attribute name="heigth" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
and for the FuitBag, i'd like to define it like a container of FruitType. It can contain Apple, and/or Banana, because Apple and Banana are FruitType.
But if i define it like this :
<xs:complexType name="FruitBag">
<xs:sequence>
<xs:element name="Fruit" type="FruitType maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
A valid XML would be :
<FruitBag>
<Fruit color="red" />
<Fruit color="orange" />
<Fruit color="yellow" />
</FuitBag>
And that's not what I want.
I don't want to define FruitBag like a container of Apple Banana, etc,
because I can have a lot of different fruits type, and if I define another kind of Fruit, i would have to add it to the declaration of my FruitBag.
So does this concept exist in XML schema ?
Or is there any way to do something like this ?
Thanks for the answers.
(Sorry if the question have allready been asked)