java - My XSD does not validate the XML despite proper namespace declarations -
the xsd <schema> tag:
<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"> the root of xml, <people> tag.
<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"> how ever en error that:
cvc-elt.1.a: cannot find declaration of element 'people' i know has namespaces can not figure out what.
please help
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>
the thing that's not working schema location attribute's namespace. xml schema instance namespace is:
http://www.w3.org/2001/xmlschema-instance
instead of:
http://www.w3c.org/2001/xmlschema-instance (you put c in w3c)
for given xml, error is
the 'http://www.w3c.org/2001/xmlschema-instance:schemalocation' attribute not declared.
Comments
Post a Comment