2
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="game">
<xsd:complexType>
<xsd:all>
<xsd:element name="info" type="infoType" minOccurs="0"/>
</xsd:all>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="infoType">
<xsd:sequence>
<xsd:element name="name" type="xsd:string" minOccurs="0" maxOccurs="1"/>
<xsd:element name="players" minOccurs="0" maxOccurs="1">
<xsd:complexType mixed="true">
<xsd:attribute name= "number" type="playernum"/>
<!-- xsd:element name="screenname" type="xsd:string">
<xsd:complexType>
<xsd:attribute name= "player" type="playernum"/>
</xsd:complexType>
</xsd:element -->
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType name="playernum">
<xsd:restriction base="xsd:int">
<xsd:minInclusive value="1"/>
<xsd:maxInclusive value="4"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>infoType
有问题的代码是注释的代码。XSD嵌套元素
它产生误差输出:
game.xsd:26:元件元素:架构分析器错误:元素 '{http://www.w3.org/2001/XMLSchema}complexType':内容不是 有效。期望的是(注解?,(简单内容|复杂内容| ((全部选择)),((属性|属性组)),anyAttribute?))))。
但有问题的元素包含默认情况下具有complexContent的complextType。 任何帮助将非常欢迎,在此先感谢。
是做到了谢谢你,我是新来的XSD,是相当明显的,虽然,你有我永远感谢,好先生;-) – Hut 2012-03-22 21:13:16