I'm trying to write an XSD for the following XML:
<?xml version="1.0" encoding="UTF-8"?>
<PersonList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="PersonList.xsd">
<Person>
<adhaarno>414356782345</adhaarno>
<name>
<firstname>Zeenath</firstname>
</name>
<age>28</age>
<address>
<doorno>33</doorno>
<street>Raidu Street</street>
<city>coimbatore</city>
<pincode>641039</pincode>
</address>
</Person>
<Person Category="seniorcitizen">
<adhaarno>414356782345</adhaarno>
<name>
<firstname>Simon</firstname>
</name>
<age>75</age>
<address>
<doorno>7</doorno>
<street>Raja Street</street>
<city>Chennai</city>
<pincode>600005</pincode>
</address>
</Person>
<Person>
<adhaarno>414356782345</adhaarno>
<name>
<lastname>Varma</lastname>
</name>
<age>25</age>
<address>
<doorno>25</doorno>
<street>cox street</street>
<city>Bangalore</city>
<pincode>560025</pincode>
</address>
</Person>
Here is my XSD code so far:
<?xml version="1.0" encoding = "utf-8"?>
<schema xlmns = "http://www.w3.org/2001/XMLSchema">
<element name="PersonList">
<complexType>
<sequence>
<element name="Person" maxOccurs="unbounded">
<complexType>
<attribute name="Category" type="string"/>
<sequence>
<element name="adhaarno"/>
<element name="name">
<complexType>
<sequence>
<element name="firstname"/>
<element name="lastname"/>
</sequence>
</complexType>
</element>
<element name="age"/>
<element name="address">
<complexType>
<sequence>
<element name="doorno"/>
<element name="street"/>
<element name="city"/>
<element name="pincode"/>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
</schema>
However, I'm getting an error as follows:
Exception: s4s-elt-schema-ns: The namespace of element 'schema' must be from the
schema namespace, 'http://www.w3.org/2001/XMLSchema'.
I tried adding and then removing the prefix, to no avail. As far as I can tell, the namespace declaration(?) is correct. What could be causing this error?
Note: please excuse the formatting issues as I had some difficulty making the XML show up correctly when I added it in.
I found the answer: I'd typed xlmns instead of xmlns.
This line of code solved it:
<schema xmlns = "http://www.w3.org/2001/XMLSchema">
Admittedly not my brightest moment.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.