B
Brett Gerhardi
Hi all, I'm trying to something that I'm sure must be possible within the
schema language but I cannot seem to work it out.
Briefly, I am defining a multi-tiered base structure - each tier has its own
complextype defined with a base CT having the structure that others should
follow.
At the leaf ends of some areas I want to restrict the type of elements that
are defined in restriction extended types but cannot find the correct way to
do it.
Take the following example. I would like to be able to define many different
specific Animal CTs based from Animal CT (Tiger, wilderbeast, giraffe etc)
and be able to define "per specific animal CT" what other specific animal
CTs can be their friend (it is unlikely a wilderbeast will be friends with a
Tiger for example ). Each specific animal CT should be able to specify an
unlimited number of elements based on Animal type, but any other type should
not be allowed.
Firstly is this actually possible to protect content models in such a way
and if so how. I can not get my head around how I can express such a type
restriction.
The following example is one technique I've tried and it is invalid ("The
content model of complex type 'MonkeyFriends' is not a valid restriction of
the contact model of complex type 'AnimalFriends')
Many thanks for any suggestions.
-=- Brett
<xs:complexType name="Animal">
<xs:choice>
<xs:element name="Friends" type="AnimalFriends"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="AnimalFriends">
<xs:choice>
<xs:element name="AnyAnimalType" type="Animal"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="Monkey">
<xs:complexContent>
<xs:restriction base="Animal">
<xs:choice>
<xs:element name="Friends" type="MonkeyFriends"/>
</xs:choice>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="MonkeyFriends">
<xs:complexContent>
<xs:restriction base="AnimalFriends">
<xs:choice>
<xs:element name="OnlyMonkeyFriends" type="Animal"/>
</xs:choice>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:schema>
schema language but I cannot seem to work it out.
Briefly, I am defining a multi-tiered base structure - each tier has its own
complextype defined with a base CT having the structure that others should
follow.
At the leaf ends of some areas I want to restrict the type of elements that
are defined in restriction extended types but cannot find the correct way to
do it.
Take the following example. I would like to be able to define many different
specific Animal CTs based from Animal CT (Tiger, wilderbeast, giraffe etc)
and be able to define "per specific animal CT" what other specific animal
CTs can be their friend (it is unlikely a wilderbeast will be friends with a
Tiger for example ). Each specific animal CT should be able to specify an
unlimited number of elements based on Animal type, but any other type should
not be allowed.
Firstly is this actually possible to protect content models in such a way
and if so how. I can not get my head around how I can express such a type
restriction.
The following example is one technique I've tried and it is invalid ("The
content model of complex type 'MonkeyFriends' is not a valid restriction of
the contact model of complex type 'AnimalFriends')
Many thanks for any suggestions.
-=- Brett
<xs:complexType name="Animal">
<xs:choice>
<xs:element name="Friends" type="AnimalFriends"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="AnimalFriends">
<xs:choice>
<xs:element name="AnyAnimalType" type="Animal"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="Monkey">
<xs:complexContent>
<xs:restriction base="Animal">
<xs:choice>
<xs:element name="Friends" type="MonkeyFriends"/>
</xs:choice>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="MonkeyFriends">
<xs:complexContent>
<xs:restriction base="AnimalFriends">
<xs:choice>
<xs:element name="OnlyMonkeyFriends" type="Animal"/>
</xs:choice>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:schema>