/ / xml prosty typ z wyliczeniem i sumą - xml, types, xsd, union, enumeration

xml typ prosty z wyliczaniem i połączeniem - xml, typy, xsd, union, enumeration

parsowanie następującego schematu xml powoduje wystąpienie tego błędu:

atrybut elementu: Błąd analizatora schematów: deklaracja atrybutu „aktualny stan”, atrybut „typ”: Wartość QName „stan objęty” nie jest rozwiązywana do (n) prostej definicji typu. Kompilacja schematu WXS memory.xsd nie powiodła się

oto kod odpowiedzialny:

<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>

Więc to, co należy zrobić, to zjednoczenie wyliczenia ciągów i liczb całkowitych, tak aby plik xml akceptował „0” lub „1” lub „COVERED” lub „UNCOVERED” dla atrybutu bieżącego stanu.

Czy ktoś może skierować mnie we właściwym kierunku? Dzięki!

Odpowiedzi:

5 dla odpowiedzi № 1

Twoje sugestie też by działały, ale rozwiązałem to w ten sposób:

    <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>

dzięki i tak!


2 dla odpowiedzi nr 2

type="covered-state" jest odniesieniem do typu bez przestrzeni nazw, ale potrzebujesz odwołania do typu o nazwie lokalnej "covered-state" w przestrzeni nazw "http://www.example.com". Aby to osiągnąć, musisz powiązać przedrostek (powiedzmy e) z tą przestrzenią nazw i nazwać ją jako type="e:covered-state".