XML Schema validation problems

M

Morten Holt

Hello group

I'm having issues validating some XML against a schema.
I'm getting the error:
org.jdom.input.JDOMParseException: Error on line 4: cvc-elt.1: Cannot
find the declaration of element 'simpleserver'.

The XML is:
<?xml version="1.0" encoding="UTF-8"?>
<simpleserver xmlns="http://simpleserver.t-hawk.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://simpleserver.t-hawk.com
SimpleServer.xsd">
<general>
<host>192.168.0.12</host>
<port>10001</port>
<logger>FileLogger</logger>
<loglevel>4</loglevel>
<password>...</password>
<logpass>...</logpass>
</general>
</simpleserver>

and as you can see the schema is located at
http://simpleserver.t-hawk.com/SimpleServer.xsd

I know it won't validate against the schema, but it should at least
validate the root element.

Any ideas and solutions would be more than welcome.
 
M

Martin Honnen

Morten said:
I'm having issues validating some XML against a schema.
I'm getting the error:
org.jdom.input.JDOMParseException: Error on line 4: cvc-elt.1: Cannot
find the declaration of element 'simpleserver'.

I am not familiar with the JDOM API and how you set it up to validate
against a schema. Have you followed the suggestions at
http://www.jdom.org/docs/faq.html#a0360?
Does your code give an error about not finding the declaration of the
root element for any kind of XML document and schema or does that only
happen for that particular document/schema combination?
 
H

Hermann Peifer

Morten said:
Hello group

I'm having issues validating some XML against a schema.
I'm getting the error:
org.jdom.input.JDOMParseException: Error on line 4: cvc-elt.1: Cannot
find the declaration of element 'simpleserver'.

The XML is:
<?xml version="1.0" encoding="UTF-8"?>
<simpleserver xmlns="http://simpleserver.t-hawk.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://simpleserver.t-hawk.com
SimpleServer.xsd">
<general>
<host>192.168.0.12</host>
<port>10001</port>
<logger>FileLogger</logger>
<loglevel>4</loglevel>
<password>...</password>
<logpass>...</logpass>
</general>
</simpleserver>

and as you can see the schema is located at
http://simpleserver.t-hawk.com/SimpleServer.xsd

I know it won't validate against the schema, but it should at least
validate the root element.

Any ideas and solutions would be more than welcome.


xmllint's error message seems to make more sense, after looking at your schema, see below.

Hermann

$ xmllint --noout --schema http://simpleserver.t-hawk.com/SimpleServer.xsd yourfile.xml
Element '{http://simpleserver.t-hawk.com}general': This element is not expected. Expected is one of ( {http://simpleserver.t-hawk.com}config, {http://simpleserver.t-hawk.com}module, {http://simpleserver.t-hawk.com}users ).
yourfile.xml fails to validate

$ xmllint --noout --schema http://simpleserver.t-hawk.com/SimpleServer.xsd myfile.xml
myfile.xml validates

$ cat myfile.xml
<?xml version="1.0" encoding="UTF-8"?>
<simpleserver xmlns="http://simpleserver.t-hawk.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://simpleserver.t-hawk.com
SimpleServer.xsd">
<config>
<general>
<host>192.168.0.12</host>
<port>10001</port>
<logger>FileLogger</logger>
<loglevel>4</loglevel>
<password>...</password>
<logpass>...</logpass>
</general>
</config>
</simpleserver>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top