Why my test xml is failing with very simple XSD Schema?
Posted
by JSteve
on Stack Overflow
See other posts from Stack Overflow
or by JSteve
Published on 2010-05-13T15:25:54Z
Indexed on
2010/05/13
15:44 UTC
Read the original article
Hit count: 359
Hi all,
I am a bit novice in xml schema. I would be grateful if somebody help me out to understand why my xml is not being validated with the schema:
Here is my Schema:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/testSchema" xmlns="http://www.example.org/testSchema">
<xs:element name="Employee">
<xs:complexType>
<xs:sequence>
<xs:element name="Name">
<xs:complexType>
<xs:sequence>
<xs:element name="FirstName" />
<xs:element name="LastName" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Here is my test xml:
<?xml version="1.0" encoding="UTF-8"?>
<Employee xmlns="http://www.example.org/testSchema">
<Name>
<FirstName>John</FirstName>
<LastName>Smith</LastName>
</Name>
</Employee>
I am getting following error by Eclipse xml editor/validator:
cvc-complex-type.2.4.a: Invalid content was found starting with element 'Name'. One of '{Name}' is expected.
I could not understand what is wrong with this schema or my xml.
© Stack Overflow or respective owner