I am trying to create an XSD to validate an element like this:
<productColor Colortype="HEX">353535</productColor>
so, I tough by my self it is so easy, I do something like this:
<xs:element name="productColor" type="xs:string">
<xs:complexType>
<xs:attribute name="Colortype" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="HEX"/>
<xs:enumeration value="RGB"/>
<xs:enumeration value="sRGB"/>
<xs:enumeration value="CMYK"/>
<xs:enumeration value="HSV"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
But, but when I've done some search I found out some body (like this link in W3 ) defined attribute but using extension , like this code:
<xs:element name="productColor">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="Colortype" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="HEX"/>
<xs:enumeration value="RGB"/>
<xs:enumeration value="sRGB"/>
<xs:enumeration value="CMYK"/>
<xs:enumeration value="HSV"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
Why? It is wrong if we go in my way?(don't use extension) and I found this link from Microsofit which says you can do it without extension. So now, I am totally confused.