Jump to content

Newbie Schema Validation Errors


ReddetEkim
 Share

Recommended Posts

Hi. I'm new to XML/Schema. I'm trying to learn a little bit about it for my own information and maybe to incorporate it into a web page. It seems correct to me but almost everything I try ends up with an error. Could someone please tell me what I'm doing wrong? Thanks a lot for any assistance. XML Schema:

<?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs="[url="http://www.w3.org/2001/XMLSchema"]http://www.w3.org/2001/XMLSchema[/url]">  <xs:element name="root_element">    <xs:complexType>	  <xs:sequence>	    <xs:element name="president">		  <xs:complexType>		    <xs:sequence>			  <xs:element name="first_name" type="xs:string"/>			  <xs:element name="last_name" type="xs:string"/>		    </xs:sequence>		  </xs:complexType>	    </xs:element>	  </xs:sequence>    </xs:complexType>  </xs:element></xs:schema>

XML Data:

<?xml version="1.0" encoding="UTF-8"?><root_element xmlns:xsi="[url="http://www.w3.org/2001/XMLSchema-instance"]http://www.w3.org/2001/XMLSchema-instance[/url]"xsi:noNamespaceSchemaLocation="test.xsd"><root_element><president><first_name>George</first_name><last_name>Washington</last_name></president><president><first_name>John</first_name><last_name>Adams</last_name></president></root_element>

Errors without <root_element> in xml file:The following errors were found: TYPE LOC MESSAGE Validation 8, 12 cvc-complex-type.2.4.d: Invalid content was found starting with element 'president'. No child element is expected at this point. Well Formed 11, 13 XML document structures must start and end within the same entity. Errors with <root_element> in XML file:The following errors were found: TYPE LOC MESSAGE Validation 4, 15 cvc-complex-type.2.4.a: Invalid content was found starting with element 'root_element'. One of '{president}' is expected. Validation 9, 12 cvc-complex-type.2.4.d: Invalid content was found starting with element 'president'. No child element is expected at this point. Well Formed 13, 16 XML document structures must start and end within the same entity.

Link to comment
Share on other sites

I think one of my problems was a missing </xs:element> since I have two simple elements. But then I got the following error: The following errors were found: TYPE LOC MESSAGE Well Formed 14, 11 The element type "xs:sequence" must be terminated by the matching end-tag "‹/xs:sequence>". I thought I had everything matched up. Sheesh!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...