Wednesday, 24 September 2014

Not understanding how root xml element is defined by schema



There is something really basic that I am apparently failing to understand, and I'm hoping someone can help. Below, I have built a really simple XML schema and XML document. Both are well-formed. But I am getting the following error when I try to validate the document against the schema:



Not valid.
Error - Line 2, 17: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 17;
cvc-elt.1: Cannot find the declaration of element 'SpecialRequest'.


I am using an online validator that I found here: http://ift.tt/1btEHxy


Here is my schema and XML.


Schema:



<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:tns="com.example.test"
elementFormDefault="qualified"
targetNamespace="com.example.test"
xmlns:xs="http://ift.tt/tphNwY">
<xs:complexType name="SpecialRequest">
<xs:sequence>
<xs:element name="content_type" nillable="true" type="xs:string" />
<xs:element name="content_data" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:element name="SpecialRequest" type="tns:SpecialRequest" />
</xs:schema>


XML:



<?xml version="1.0" encoding="UTF-8"?>
<SpecialRequest>
</SpecialRequest>


The validator can't find the SpecialRequest element. I don't get it. What am I missing? Thanks.


P.S.


I took out any identifying information to simplify things and hide the client's identity. That's why you see com.example.test.


No comments:

Post a Comment