【发布时间】:2016-02-04 19:58:18
【问题描述】:
我在使用架构验证 XML 文件时出错。
s4s-elt-invalid-content.1: '#AnonType_userusersroot' 的内容是 无效的。元素“序列”无效、错位或也出现 经常。 [25]
我的 XML 文件:
<root>
<users>
<user code="10">
<fullName>sandesh poudel</fullName>
<sex>male</sex>
<age>19</age>
<phoneNo>239239</phoneNo>
<address>Rasinkatu 13</address>
<title>owner</title>
</user>
<user code ="20">
<fullName>Surendra pandey</fullName>
<sex>male</sex>
<age>22</age>
<phoneNo>3432</phoneNo>
<address>kilo 13</address>
<title>manager</title>
</user>
<user code ="40">
<fullName>sangam poudel</fullName>
<sex>male</sex>
<age>22</age>
<phoneNo>239239</phoneNo>
<address>sydney</address>
<title>Programmer</title>
</user>
</users>>
</root>
我的 XML 架构文件:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com"
elementFormDefault="qualified">
<xs:element name="root">
<xs:complexType mixed="true">
<xs:sequence maxOccurs="unbounded">
<xs:element name="users">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element name="user">
<xs:complexType mixed="true">
<xs:attribute name="code" type="xs:string"/>
<xs:sequence>
<xs:element name="fullName" type="xs:string"/>
<xs:element name="sex" type="xs:string"/>
<xs:element name="age" type="xs:string"/>
<xs:element name="phoneNo" type="xs:string"/>
<xs:element name="address" type="xs:string"/>
<xs:element name ="title" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element> <!-- name -->
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
【问题讨论】:
标签: xml xsd xml-validation