找不到元素 XML 的声明
Cannot find the declaration of element XML
我是 XML 的初学者。
我创建了一个 XSD 和另一个 XML 文件来检查一些验证。检查验证后提示一条错误消息我无法修复它。
--- 下面 XSD 我创建了
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Employee"
elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="EmployeeType">
<xs:sequence>
<xs:element name="Name" type="xs:string" />
<xs:element name="Address" type="xs:string"
minOccurs="1" maxOccurs="unbounded" />
<xs:element name="Phone" type="xs:string"
minOccurs="1" maxOccurs="3" />
<xs:element name="DateOfBirth" type="xs:date" />
</xs:sequence>
<xs:attribute name="Empno" type="xs:integer" />
</xs:complexType>
<xs:complexType name="Employees">
<xs:sequence>
<xs:element name="Employee" type="EmployeeType"
minOccurs="0" maxOccurs="4" />
</xs:sequence>
</xs:complexType>
</xs:schema>
--这里是我输入的数据XML
<?xml version="1.0" encoding="utf-8" ?>
<Employees>
<Employee Empono ="001">
<Name>Alex</Name>
<Adress>Florida</Adress>
<Phone>1234567890</Phone>
<DateOfBirth>10-09-1991</DateOfBirth>
</Employee>
<Employee Empono ="002">
<Name>Lynda</Name>
<Adress>Florida</Adress>
<Phone>1234567890</Phone>
<DateOfBirth>1-12-1991</DateOfBirth>
</Employee>
</Employees>
验证后提示我这条消息:(
Cannot find the declaration of element 'Employees'.
您需要有一个 <xs:element>
标签作为最外层的包装器,它定义了 <Employees>
标签:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Employee" elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="EmployeeType">
<xs:sequence>
<xs:element name="Name" type="xs:string" />
<xs:element name="Address" type="xs:string" minOccurs="1"
maxOccurs="unbounded" />
<xs:element name="Phone" type="xs:string" minOccurs="1"
maxOccurs="3" />
<xs:element name="DateOfBirth" type="xs:date" />
</xs:sequence>
<xs:attribute name="Empno" type="xs:integer" />
</xs:complexType>
<xs:element name="Employees">
<xs:complexType name="EmployeesType">
<xs:sequence>
<xs:element name="Employee" type="EmployeeType" minOccurs="0"
maxOccurs="4" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
我是 XML 的初学者。 我创建了一个 XSD 和另一个 XML 文件来检查一些验证。检查验证后提示一条错误消息我无法修复它。
--- 下面 XSD 我创建了
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Employee"
elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="EmployeeType">
<xs:sequence>
<xs:element name="Name" type="xs:string" />
<xs:element name="Address" type="xs:string"
minOccurs="1" maxOccurs="unbounded" />
<xs:element name="Phone" type="xs:string"
minOccurs="1" maxOccurs="3" />
<xs:element name="DateOfBirth" type="xs:date" />
</xs:sequence>
<xs:attribute name="Empno" type="xs:integer" />
</xs:complexType>
<xs:complexType name="Employees">
<xs:sequence>
<xs:element name="Employee" type="EmployeeType"
minOccurs="0" maxOccurs="4" />
</xs:sequence>
</xs:complexType>
</xs:schema>
--这里是我输入的数据XML
<?xml version="1.0" encoding="utf-8" ?>
<Employees>
<Employee Empono ="001">
<Name>Alex</Name>
<Adress>Florida</Adress>
<Phone>1234567890</Phone>
<DateOfBirth>10-09-1991</DateOfBirth>
</Employee>
<Employee Empono ="002">
<Name>Lynda</Name>
<Adress>Florida</Adress>
<Phone>1234567890</Phone>
<DateOfBirth>1-12-1991</DateOfBirth>
</Employee>
</Employees>
验证后提示我这条消息:(
Cannot find the declaration of element 'Employees'.
您需要有一个 <xs:element>
标签作为最外层的包装器,它定义了 <Employees>
标签:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Employee" elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="EmployeeType">
<xs:sequence>
<xs:element name="Name" type="xs:string" />
<xs:element name="Address" type="xs:string" minOccurs="1"
maxOccurs="unbounded" />
<xs:element name="Phone" type="xs:string" minOccurs="1"
maxOccurs="3" />
<xs:element name="DateOfBirth" type="xs:date" />
</xs:sequence>
<xs:attribute name="Empno" type="xs:integer" />
</xs:complexType>
<xs:element name="Employees">
<xs:complexType name="EmployeesType">
<xs:sequence>
<xs:element name="Employee" type="EmployeeType" minOccurs="0"
maxOccurs="4" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>