Sorry for coming in on this late, but I can't get (a variant of) the example
to work. The xml is:
<?xml version="1.0"?>
<Tester colour="dark red"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema"
xsi:noNamespaceSchemaLocation="D:\andyp\xml\tester.xsd">
<dummy>hello world</dummy>
</Tester>
The xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema">
<xsd:simpleType name="colours">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="red"/>
<xsd:enumeration value="dark red"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="Tester">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="dummy" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="colour" type="colours"/>
<xsd:attribute name="xsi:schemaLocation" type="xsd:string"/>
<xsd:attribute name="xmlns:xsi" use="default"
value="http://www.w3.org/2000/10/XMLSchema" type="xsd:uriReference"/>
<xsd:attribute name="xsi:noNamespaceSchemaLocation" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Using XMLSpy 3.5b1 the xsd is fine, but the xml gives the error (on line 2):
"Unexpected choice 'dark red' for attribute 'colour': (red|dark|red)
expected.
What am I doing wrong (I've included everything in case I've missed
something blindingly obvious)? There's not much about this topic on the web,
but there must be loads of uses - my need is actually to limit an element to
a set of names, and that must be quite common.