解析以下xml架构会产生此错误: element属性:Schemas解析器错误:属性decl. ‘current-state’,属性’type’:QName值’covered-state’不解析为(n)简单类型定义. WXS模式memory.xsd无法编译 继承人负责
element属性:Schemas解析器错误:属性decl. ‘current-state’,属性’type’:QName值’covered-state’不解析为(n)简单类型定义.
WXS模式memory.xsd无法编译
继承人负责的代码:
<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>
所以这应该做的是联合字符串和整数的枚举,以便xml文件接受属性当前状态的“0”或“1”或“覆盖”或“未密封”.
有人能指出我正确的方向吗?谢谢!
你的建议也会奏效,但我这样解决了:<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>
不管怎么说,还是要谢谢你!
