Found a misplaced document type declaration (<!DOCTYPE ... >)

For technical support and bug reports for all editions of CSS HTML Validator, including htmlval for Linux and Mac.
User avatar
anv2010
Rank II - Novice
Posts: 34
Joined: Wed May 05, 2010 4:41 pm

Found a misplaced document type declaration (<!DOCTYPE ... >)

Post by anv2010 »

Hello Albert,

The validator reports this error:
Found a misplaced document type declaration (<!DOCTYPE ... >). The DOCTYPE should normally be the first line of the document. An exception is for XML based documents where the first line is normally the XML declaration (<?xml ... >) and the second line is the document type declaration.

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><title>C...
However, the <!DOCTYPE html> is on the first line.

I've just updated to product version 17.0230. The previous release of the product didn't issue this error message.

Thank you.
Conversions and Calculations
https://www.aqua-calc.com
User avatar
Albert Wiersch
Site Admin
Posts: 3785
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX

Re: Found a misplaced document type declaration (<!DOCTYPE ... >)

Post by Albert Wiersch »

Hello,

I'm sorry for the trouble. I cannot reproduce this. Can you email me the complete document or a sample document that reproduces the problem via email attachment to support at htmlvalidator dot com? Thanks!
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
User avatar
anv2010
Rank II - Novice
Posts: 34
Joined: Wed May 05, 2010 4:41 pm

Re: Found a misplaced document type declaration (<!DOCTYPE ... >)

Post by anv2010 »

Hello Albert,

I've just sent you the email.

Thank you!
Conversions and Calculations
https://www.aqua-calc.com
User avatar
Albert Wiersch
Site Admin
Posts: 3785
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX

Re: Found a misplaced document type declaration (<!DOCTYPE ... >)

Post by Albert Wiersch »

Thank you. I've received all the files and am trying to figure out the cause of this problem.

You said this didn't happen in your prior version. Do you know what version you were using just prior to 17.0230?
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
User avatar
anv2010
Rank II - Novice
Posts: 34
Joined: Wed May 05, 2010 4:41 pm

Re: Found a misplaced document type declaration (<!DOCTYPE ... >)

Post by anv2010 »

Version 15, my command script with which I invoke your Batch Wizard used to point to HTMLValidator150
Conversions and Calculations
https://www.aqua-calc.com
User avatar
Albert Wiersch
Site Admin
Posts: 3785
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX

Re: Found a misplaced document type declaration (<!DOCTYPE ... >)

Post by Albert Wiersch »

This issue has been resolved! It turned out to be a server issue. An improvement has been made to the generated DOCTYPE message to make problems like this easier to diagnose in the future. The change will be in the next update (v17.0232+).
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
User avatar
anv2010
Rank II - Novice
Posts: 34
Joined: Wed May 05, 2010 4:41 pm

Re: Found a misplaced document type declaration (<!DOCTYPE ... >)

Post by anv2010 »

To start with, I'd like to Thank Albert for his stellar support -- Thank you, Albert!

It was a server issue, and these are the details:
  • The CSE HTML Validator Batch Wizard starts 10 concurrent HTTP requests.
  • Server assigns the same PHP session ID to all these 10 requests (10 user agents).
  • Each one of these 10 user agents attempts to reference (open, read, write, close) the same session object.
  • PHP maintains session locks.
  • 1 or more of these 10 user agents fall victim to such session lock after a certain timeout.
  • PHP server adds the following two lines to the top of each page, that fails to acquire a PHP session:

    Code: Select all

    <b>Warning</b>: session_start(): Unable to clear session lock record in <b>/my_path/my_php_script.php</b> on line <b>nnn</b><br />
Thus, the failed pages do not start with <!DOCTYPE html> line. I was able to identify the problem, after Albert had modified the Batch Wizard to show a line previous to the <!DOCTYPE html> string.

I've changed the Max concurrent HTTP requests to 1. See CSE HTML Validator Ent Batch Wizard Options -> Limits
The Batch Wizard runs fine, but processes only 1 URL at a time.

Fortunately for me, Albert had suggested (and explained how) to split my batch wizard into several jobs which run in parallel.
Here's my Windows command script:

Code: Select all

"C:\Program Files (x86)\HTMLValidator170\cmdlineprocessor.exe" -f "C:\data\cse\cmdstack-split.txt"
and here's the cmdstack-split.txt file:

Code: Select all

-msgwindow CSEconvert -b "C:\data\cse\my-website-convert.lst"
-msgwindow CSEConDen -b "C:\data\cse\my-website-convert-density.lst"
-msgwindow CSEfood -b "C:\data\cse\my-website-calculate.lst"
-msgwindow CSEonly -b "C:\data\cse\my-website-only.lst"
-msgwindow CSEconvert -q
-msgwindow CSEConDen -q
-msgwindow CSEfood -q
-msgwindow CSEonly -q
Each list in the above file references a part of my website.
As a result, I've four jobs scanning my website in parallel without session locks and timeouts.

I hope, my lengthy reply might help someone in the future.

Thank you!
Conversions and Calculations
https://www.aqua-calc.com