J
Joshua Mostafa
Hi there.
I have a question regarding restrictions in an XML Schema definition.
My XML contains a structure like this:
<fruit-bowl>
<fruit name="apple" />
<fruit name="pear" />
<fruit name="lychee" favourite="true" />
</fruit-bowl>
The problem is that it should be impossible to specify more than one
favourite. However, I don't know how to write this rule in XSD. I need
to restrict the number of elements *with a certain attribute value*.
Any ideas?
Everything else is there ... this is as far as I've got:
<xs:complexType name="FruitBowlType">
<xs:sequence>
<xs:element name="module" type="FruitType" minOccurs="1"
maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="FruitType">
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="favourite" type="boolean" />
</xs:complexType>
I have a question regarding restrictions in an XML Schema definition.
My XML contains a structure like this:
<fruit-bowl>
<fruit name="apple" />
<fruit name="pear" />
<fruit name="lychee" favourite="true" />
</fruit-bowl>
The problem is that it should be impossible to specify more than one
favourite. However, I don't know how to write this rule in XSD. I need
to restrict the number of elements *with a certain attribute value*.
Any ideas?
Everything else is there ... this is as far as I've got:
<xs:complexType name="FruitBowlType">
<xs:sequence>
<xs:element name="module" type="FruitType" minOccurs="1"
maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="FruitType">
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="favourite" type="boolean" />
</xs:complexType>