No grammar constraints (DTD or XML schema) detected for the document No grammar constraints (DTD or XML schema) detected for the document xml xml

No grammar constraints (DTD or XML schema) detected for the document


In my case I have solved this annoying warning by simply adding the <!DOCTYPE xml> after the <?xml ... > tag.

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE xml>


This worked for me in Eclipse 3.7.1: Go to the Preferences window, then XML -> XML Files -> Validation. Then in the Validating files section of the preferences panel on the right, choose Ignore in the drop down box for the "No grammar specified" preference. You may need to close the file and then reopen it to make the warning go away.

(I know this question is old but it was the first one I found when searching on the warning, so I'm posting the answer here for other searchers.)


Answer:

Comments on each piece of your DTD below. Refer to official spec for more info.

  <!  DOCTYPE ----------------------------------------- correct  templates --------------------------------------- correct  Name matches root element.  PUBLIC ------------------------------------------ correct  Accessing external subset via URL.  "//UNKNOWN/" ------------------------------------ invalid? Seems useless, wrong, out-of-place.                                                             Safely replaceable by DTD URL in next line.  "http://fast-code.sourceforge.net/template.dtd" - invalid  URL is currently broken.  >

Simple Explanation:

An extremely basic DTD will look like the second line here:

<?xml version="1.0" encoding="utf-8"?><!DOCTYPE nameOfYourRootElement><nameOfYourRootElement></nameOfYourRootElement>

Detailed Explanation:

DTDs serve to establish agreed upon data formats and validate the receipt of such data. They define the structure of an XML document, including:

  • a list of legal elements
  • special characters
  • character strings
  • and a lot more

E.g.

<!DOCTYPE nameOfYourRootElement[<!ELEMENT nameOfYourRootElement (nameOfChildElement1,nameOfChildElement2)><!ELEMENT nameOfChildElement1 (#PCDATA)><!ELEMENT nameOfChildElement2 (#PCDATA)><!ENTITY nbsp "&#xA0;"> <!ENTITY author "Your Author Name">]>

Meaning of above lines...
Line 1) Root element defined as "nameOfYourRootElement"
Line 2) Start of element definitions
Line 3) Root element children defined as "nameOfYourRootElement1" and "nameOfYourRootElement2"
Line 4) Child element, which is defined as data type #PCDATA
Line 5) Child element, which is defined as data type #PCDATA
Line 6) Expand instances of   to &#xA0; when document is parsed by XML parser
Line 7) Expand instances of &author; to Your Author Name when document is parsed by XML parser
Line 8) End of definitions