【发布时间】:2009-05-05 15:35:52
【问题描述】:
我正在尝试编写一个验证以下 XML 的架构:
<category type="rifles">
<item>
<name>
AK47
</name>
<description>
The USSR's chief export back in the day, and the guerrilla's best friend. On African flags than any other symbol.
</description>
<cost>
4000
</cost>
<image>
ak47.jpg
</image>
<provenance>
The USSR.
</provenance>
<quantity>
10000
</quantity>
</item>
(省略了其他项目元素,多余的标题标签和结束标签。)
并开发了以下架构:
<element name="store">
<complexType>
<sequence>
<element name="category" maxOccurs="unbounded" >
<complexType>
<simpleContent>
<extension base="string">
<attribute name="type" type="string" />
</extension>
</simpleContent>
<sequence>
<element name="item" maxOccurs="unbounded" >
<complexType>
<sequence>
<element name="name" type="string"/>
<element name="description" type="string"/>
<element name="image" type="string"/>
<element name="cost" type="number"/>
<element name="provenence" type="string"/>
<element name="quantity" type="number"/>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
使用http://www.xmlme.com/Validator.aspx?mid=83 的验证器,我得到:
架构错误:System.Xml.Schema.XmlSchemaException:复杂类型的内容模型必须包含“注释”(如果存在);后跟零或以下之一:“simpleContent”、“complexContent”、“group”、“choice”、“sequence”或“all”;后跟零个或多个“属性”或“属性组”;后跟零个或一个“anyAttribute”。
我知道这听起来很傻,但是谁能指出我的错误?
【问题讨论】: