P
Piers Chivers
Hi,
I need to restrict the allowed included elements dependent upon the value of
another element. How do I do this using XML Schema?
For example, the XML
<Petshop>
<Kind>Dog</Kind>
<Breeds>
<Breed>Poodle</Breed>
<Breed>Alsatian</Breed>
</Breeds>
</Petshop>
is valid because the element <Breeds> is allowed when the element <Kind> has
a value of 'Dog'. However
<Petshop>
<Kind>Fish</Kind>
<Breeds>
<Breed>Poodle</Breed>
<Breed>Alsatian</Breed>
</Breeds>
</Petshop>
is not valid because the element <Breeds> is not allowed when the element
<Kind> has a value of 'Fish'.
How do I describe this using XML schema? Also, how would I say the element
<Breeds> is mandated when the value is 'Dog', and the element <WaterType> is
mandated when the value is 'Fish'?
Many thanks,
Piers
I need to restrict the allowed included elements dependent upon the value of
another element. How do I do this using XML Schema?
For example, the XML
<Petshop>
<Kind>Dog</Kind>
<Breeds>
<Breed>Poodle</Breed>
<Breed>Alsatian</Breed>
</Breeds>
</Petshop>
is valid because the element <Breeds> is allowed when the element <Kind> has
a value of 'Dog'. However
<Petshop>
<Kind>Fish</Kind>
<Breeds>
<Breed>Poodle</Breed>
<Breed>Alsatian</Breed>
</Breeds>
</Petshop>
is not valid because the element <Breeds> is not allowed when the element
<Kind> has a value of 'Fish'.
How do I describe this using XML schema? Also, how would I say the element
<Breeds> is mandated when the value is 'Dog', and the element <WaterType> is
mandated when the value is 'Fish'?
Many thanks,
Piers