I am trying to write an XML Schema for validating the line characteristics described by the following XML code:
<linecharacteristics>
<characteristic name = "color" value = "red" />
<characteristic name = "style" value = "dashed" />
...
<characteristic name = "thickness" value = "medium" />
</linecharacteristics>
There are multiple characteristics and this is the XML Schema code that I have so far:
<xs:element name="linecharacteristics">
<xs:complexType>
<xs:sequence>
<xs:element name="characteristic" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="value" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
What I am trying to figure out is how to check whether the attributes are correct. For example, the "name" attribute can say 'color', 'style', and 'thickness' but not 'shape'. Also, if the attribute "name" says 'color', then the "values" can only contain 'red', 'yellow', 'green' and not 'dashed'; 'dashed' value is only associated with the name 'style'. So how do I define what are the acceptable attribute value sets?
Thanks for your help!