Reputation: 57
hello I have been looking on this isse for about an hour and I couldnt find what that even should mean.
Here is my XML shema code:
<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>
and here is the parser error that I get for it.
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
This is for a university project, and I have to turned in in 6 hours. I hope I can find a solution in this time.
Thanks
Upvotes: 1
Views: 8117
Reputation: 4075
In the element definition for screenname
(game.xsd:25
) both defined the element type to be xsd:string
in an attribute AND defined it as a complexType
using a child element. You are probably looking for a type with a specific attribute and a string content?
<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>
Upvotes: 4