你好,我一直在寻找这个问题大约一个小时,我找不到甚至应该是什么意思。
这是我的XML shema代码:
<xsd:element name="game">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="info" minOccurs="0" maxOccurs="1" type="infoType">
</xsd:element>
<xsd:element name="moves" type="movesType" minOccurs="1">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="infoType">
<xsd:sequence>
<xsd:element name="name" minOccurs="0" maxOccurs="1" type="xsd:string"></xsd:element>
<xsd:element name="description" minOccurs="0" maxOccurs="1" type="descriptionType">
</xsd:element>
<xsd:element name="started" type="xsd:dateTime"></xsd:element>
<xsd:element name="players" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="screenname" minOccurs="0" maxOccurs="4" type="xsd:string">
<xsd:complexType>
<xsd:attribute name="player" use="required"> </xsd:attribute>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="number" type="xsd:integer" use="required"></xsd:attribute>
</xsd:complexType>
</xsd:element>
<xsd:element name="rounds" minOccurs="0" maxOccurs="1" type="xsd:integer"></xsd:element>
<xsd:element name="winner" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:attribute name="player" type="playerType" use="required"></xsd:attribute>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="movesType">
<xsd:choice maxOccurs="unbounded">
<xsd:element name="roll" >
<xsd:complexType>
<xsd:simpleContent>
<xsd:restriction base="xsd:integer">
<xsd:minInclusive value="1"></xsd:minInclusive>
<xsd:maxInclusive value="6"></xsd:maxInclusive>
</xsd:restriction>
</xsd:simpleContent>
<xsd:attribute name="player" type="playerType"></xsd:attribute>
</xsd:complexType>
</xsd:element>
<xsd:element name="piece">
<xsd:complexType>
<xsd:attribute name="player" type="playerType" use="required"></xsd:attribute>
<xsd:attribute name="nr" type="xsd:integer" use="required">
<xsd:simpleType>
<xsd:restriction base="xsd:integer">
<xsd:minInclusive value="1"></xsd:minInclusive>
<xsd:maxInclusive value="16"></xsd:maxInclusive>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="field" type="xsd:integer" use="required">
<xsd:simpleType>
<xsd:restriction base="xsd:integer">
<xsd:minInclusive value="1"></xsd:minInclusive>
<xsd:maxInclusive value="72"></xsd:maxInclusive>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
<xsd:simpleType name="playerType" >
<xsd:restriction base="xsd:integer">
<xsd:minInclusive value="1"></xsd:minInclusive>
<xsd:maxInclusive value="4"></xsd:maxInclusive>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="descriptionType" mixed="true">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="i" type="descriptionType" ></xsd:element>
<xsd:element name="b" type="descriptionType"></xsd:element>
</xsd:choice>
</xsd:complexType>
这是我得到的解析器错误。
game.xsd:25:
element complexType:
Schemas parser error :
Element '{http://www.w3.org/2001/XMLSchema}element':
The attribute 'type' and the child are mutually exclusive.
game.xsd:51:
element attribute:
Schemas parser error :
Element '{http://www.w3.org/2001/XMLSchema}complexType':
The content is not valid. Expected is (annotation?, (simpleContent | complexContent | ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?)))).
game.xsd:58:
element simpleType:
Schemas parser error :
Element '{http://www.w3.org/2001/XMLSchema}attribute':
The attribute 'type' and the child are mutually exclusive.
game.xsd:66:
element simpleType:
Schemas parser error :
Element '{http://www.w3.org/2001/XMLSchema}attribute':
The attribute 'type' and the child are mutually exclusive. WXS schema game.xsd failed to compile
这是一个大学项目,我必须在6个小时内上交。我希望我能在这个时候找到解决方案。
由于
答案 0 :(得分:3)
在screenname
(game.xsd:25
)的元素定义中,两者都将元素类型定义为属性中的xsd:string
,并使用子元素将其定义为complexType
。您可能正在寻找具有特定属性和字符串内容的类型?
<xsd:element name="screenname" minOccurs="0" maxOccurs="4">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="player" use="required" type="xsd:string" />
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>