XSD<schema>
标签:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.cmu.edu/ns/blank"
targetNamespace="http://www.cmu.edu/ns/blank"
elementFormDefault="qualified">
XML 的根,<people>
标记。
<people
xmlns="http://www.cmu.edu/ns/blank"
xmlns:xsi="http://www.w3c.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.cmu.edu/ns/blank student.xsd">
我怎么会出错:
cvc-elt.1.a: Cannot find the declaration of element 'people'
我知道它与命名空间有关,但我不知道是什么。
请帮忙
XML
<?xml version="1.0" encoding="UTF-8" ?>
<!-- <!DOCTYPE people SYSTEM "validator.dtd"> -->
<people
xmlns="http://www.cmu.edu/ns/blank"
xmlns:xsi="http://www.w3c.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.cmu.edu/ns/blank student.xsd">
<student>
<name>John</name>
<course>Computer Technology</course>
<semester>6</semester>
<scheme>E</scheme>
</student>
<student>
<name>Foo</name>
<course>Industrial Electronics</course>
<semester>6</semester>
<scheme>E</scheme>
</student>
</people>
XSD
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.cmu.edu/ns/blank"
targetNamespace="http://www.cmu.edu/ns/blank"
elementFormDefault="qualified">
<xs:element name="people">
<xs:complexType>
<xs:sequence>
<xs:element name="student" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string" />
<xs:element name="course" type="xs:string" />
<xs:element name="semester">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="1" />
<xs:enumeration value="2" />
<xs:enumeration value="3" />
<xs:enumeration value="4" />
<xs:enumeration value="5" />
<xs:enumeration value="6" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="scheme">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value = "E|C" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>