XHTML validation fails: Cannot find the declaration...

Questions about XML that are not covered by the other forums should go here.
rpaehlig
Posts: 2
Joined: Tue Dec 13, 2005 11:53 pm

XHTML validation fails: Cannot find the declaration...

Post by rpaehlig » Wed Dec 14, 2005 12:09 am

I tried to validate the following XHTML:

Code: Select all

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-strict.dtd">
<html xmlns:html="http://www.w3.org/1999/xhtml">
<head>
<title>Test XHTML</title>
</head>
<body>
<h1>Test</h1>
</body>
</html>
I got: SystemID: /Users/rpaehlig/Applications/oxygen/Unbenannt4.xml
Position: 3:49
Beschreibung: E cvc-elt.1: Cannot find the declaration of element 'html'.
URL: http://www.w3.org/TR/xmlschema-1/#cvc-elt

I see the model being updated when i move the cursor, so I assume, the DTD has been read. What's wrong? TIA!

george
Site Admin
Posts: 2101
Joined: Thu Jan 09, 2003 2:58 pm

Post by george » Wed Dec 14, 2005 11:48 am

Hi,

From the error message it looks like a schema validation was performed and there is no schema asssociated with the document thus the error. Please make sure you have disable the "Use only XML Schema for validation" option in the Options->Preferences / XML / XML Parser preference page, otherwise the DTD will be ignored for validation and the validation against XML Schema will be tried.

On the other hand your document does not declare correctly the namespace for the html element, instead of declaring a default namespace as the html element has no prefic, it declares a namespace bound to the html prefix which is not used in your document. You need something like:

Code: Select all


<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test XHTML</title>
</head>
<body>
<h1>Test</h1>
</body>
</html>
Best Regards,
George

rpaehlig
Posts: 2
Joined: Tue Dec 13, 2005 11:53 pm

Post by rpaehlig » Tue Dec 20, 2005 1:59 pm

Thank you. That does the job.

I was not aware of this config option. The german translation of this switches label reads 'Use XML Schema for validation' instead of 'Use only XML Schema for validation', which suggested to me that, if disabled, the parser won't use XML Schemas at all anymore. Maybe this minor localization issue should be corrected. The proper german label would be: 'Nur XML Schema für Validierung benutzen'.

Thank you for pointing out that namespace issue too.

Best regards

--
Robby

Post Reply