parsing the following xml schema produces this error:
element attribute: Schemas parser error : attribute decl. 'current-state', attribute 'type': The QName value 'covered-state' does not resolve to a(n) simple type definition. WXS schema memory.xsd failed to compile
heres the responsible code:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.com">
<xsd:simpleType name="covered-state">
<xsd:union>
<xsd:simpleType>
<xsd:restriction base="xsd:integer">
<xsd:enumeration value="0"/>
<xsd:enumeration value="1"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="COVERED"/>
<xsd:enumeration value="UNCOVERED"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:union>
</xsd:simpleType>
<xsd:complexType name="MemoryCard">
<xsd:attribute name="current-state" type="covered-state" use="required"/> <!-- here i get the error -->
</xsd:complexType>
</xsd:schema>
So what this is supposed to do is to union an enumeration of strings and ints so that the xml file accepts "0" or "1" or "COVERED" or "UNCOVERED" for attribute current state.
Can someone point me in the right direction? Thanks!
your suggestions would work too but i solved it like this:
<xsd:attribute name="current-state" use="required">
<xsd:simpleType>
<xsd:union>
<xsd:simpleType>
<xsd:restriction base="xsd:integer">
<xsd:enumeration value="0"/>
<xsd:enumeration value="1"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="COVERED"/>
<xsd:enumeration value="UNCOVERED"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:union>
</xsd:simpleType>
</xsd:attribute>
thanks anyway!
type="covered-state"
is a reference to a type in no namespace, but you want a reference to a type with local name "covered-state"
in namespace "http://www.example.com"
. To achieve that you need to bind a prefix (say e) to this namespace and refer to it as type="e:covered-state"
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With