java - cvc-elt.1.a: Cannot find the declaration of element 'people' -
i trying validate xml document using xsd. have tried providing namespaces everything, including default. however, error persists. if please tell me going wrong highly appreciated
<?xml version="1.0" encoding="utf-8" ?> <!-- <!doctype people system "validator.dtd"> --> <people xmlns:cmuq="http://www.cmu.edu/ns/students" xmlns="http://www.cmu.edy/ns/blank" xmlns:xsi="http://www.w3c.org/2001/xmlschema-instance" xsi:schemalocation="student.xsd" > <cmuq:student> <name>john</name> <course>computer technology</course> <semester>6</semester> <scheme>e</scheme> </cmuq:student> <cmuq:student> <name>foo</name> <course>industrial electronics</course> <semester>6</semester> <scheme>e</scheme> </cmuq: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/students"> <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>
please tell me how solve error
update after ian roberts' answer
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">
it still not validate. have, now, dropped idea of adding xmlns:cmuq
problem persists. >
the schema have there declares people
element in http://www.cmu.edu/ns/students
namespace (the target namespace of schema) , nested elements in no namespace (because don't use elementformdefault
). needs be
<cmuq:people xmlns:cmuq="http://www.cmu.edu/ns/students" xmlns:xsi="http://www.w3c.org/2001/xmlschema-instance" xsi:schemalocation="http://www.cmu.edu/ns/students student.xsd" > <student>
note xsi:schemalocation
needs list of namespaceuri schema
pairs, not single schema address - attribute can associate different schema each namespace.
Comments
Post a Comment