This test runs an XML parser on your document to check if your page validates against its specified schema. A schema (or DTD) constrains the structure and content of an XML document. An XML document which is well-formed and which complies with its schema is said to be valid. Put simply, the schema specifies rules about the structure and content of a document, and your document must follow these rules (as well as general XML well-formedness rules). If the XML parser finds something wrong with your document, then an error message will be displayed. Some errors cause the parser to stop dead in its tracks, while some errors are not so serious, and the parser can continue.
Understanding the validator error messages
The output of the validator can sometimes be misleading. A list of the most common messages and their remedies are included below:
The content of element type "body" must match…
The content of element type "form" must match…
The reference to entity "&" must end with the ';' delimiter.
Attribute "attr" must be declared for element type "element".
Element type "element" must be declared.
White spaces are required between publicId and systemId.
The system identifier must begin with either a single or double quote character.
Content is not allowed in prolog.
The processing instruction target matching "[xX][mM][lL]" is not allowed.
XML document structures must start and end within the same entity.
The element type "element" must be terminated by the matching end-tag "</element>".
The processing instruction must begin with the name of the target.
Open quote is expected for attribute "attr" associated with an element type "element".
The content of element type "body" must match "(h1|h2|h3|h4|h5|h6|ul|ol|dl|p|div|pre|blockquote|address|hr|table|form|fieldset)*".
Cause:
Only certain tags are allowed immediately after the <body> tag
Solution: This message indicates that markup immediately following the tag should be one of the tags in the list e.g.
Incorrect:
1
2
3
|
<body>
Hello World!
</body>
|
Correct:
1
2
3
4
5
|
<body>
<p>
Hello World!
</p>
</body>
|
The content of element type "form" must match "(h1|h2|h3|h4|h5|h6|ul|ol|dl|p|div|pre|blockquote|address|hr|table|fieldset)+".
Cause: Only certain tags are allowed immediately after the <form>
tag
Solution: This message is very similar to the previous one. Markup immediately following the <form>
tag should be one of the tags in the list:
The reference to entity "&" must end with the ';' delimiter.
Cause: This message is often displayed where the '&' characters in a URL have not been converted to their corresponding XML entity.
Solution: Escape special characters such as '&'
Correct:
1 |
<a href="http://example.mobi?fname=joe&lname=blogs">...</a>
|
Incorrect:
1 |
<a href="http://example.mobi?fname=joe&lname=blogs">...</a>
|
Attribute "attr_name" must be declared for element type "element_name".
Cause:
This type of message simply means that you may not include attribute attr_name for the element element_name.
Solution: To fix the problem, simply omit the offending attribute: e.g. if you receive the message:
Attribute "name" must be declared for element type "form".
Remove the name attribute e.g.
1 |
<form name="myform" id="myform" ...>
|
becomes