Fixit – Valid Markup

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:

Correct:

 

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:

Incorrect:

 

 

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.

becomes

And if you receive the message:

Attribute "cellpadding" must be declared for element type "table".

Remove the cellpadding attribute e.g.

<table cellpadding="10px" ...>
becomes <table>

 

If the attribute is a styling attribute and you want to maintain your styling, then you could move the attribute from the tag markup and into a stylesheet. For example, the line:

<td bgcolor="#009900" height="25">Hello World!</td>

 

would produce the following validation errors:


Attribute "bgcolor" must be declared for element type "td".
Attribute "height" must be declared for element type "td".

 

To remedy this without losing your styling, you move the attributes bgcolor and height into a CSS style. So the original markup becomes:

 

And a new style called mystyle is defined:

 

However, you need to be careful here. Sometimes the CSS attributes have different names to their HTML counterparts. In this case bgcolor becomes background-color, and height becomes line-height. Please refer to the CSS specification to find out what attributes are available to use.

 

Element type “element_name” must be declared.

Cause: This means that the element “element_name” has not been specified in the DTD. Thus, it can't be used in your document.

Solution: To remedy, simpy remove the tag.
This applies to any error message of the form e.g.

If you receive the message:

Element type "font" must be declared.

Then you should remove the occurence of the <font> tag from your markup.

 

 

White spaces are required between publicId and systemId.

Cause: There is no space between the public and system identifiers in the DOCTYPE declaration

Solution: To fix this, simply put a space, a newline, or a tab between the public and system identifiers in the DOCTYPE declaration e.g.

Correct:

 

Incorrect:

 

 

The system identifier must begin with either a single or double quote character.

Cause: The system identifier (a URL to a copy of the DTD) of the DOCTYPE declaration is not surrounded by quotes

Solution: Put quotes around the system id e.g.

Incorrect:

 

Correct:

 

 

Content is not allowed in prolog.

Cause: There is extraneous text at the beginning of the document.

Solution: Remove any text occuring before the XML declaration. Comments are allowed, but must not occur before the XML decalaration e.g.

Not permitted:

 

Not permitted:

 

Permitted:

 

 

The processing instruction target matching “[xX][mM][lL]” is not allowed.

Cause: This message can occur where there is extraneous text at the very beginning of the document.

Solution: Remove any text preceding the XML declaration. Comments are permitted before the DOCTYPE declaration, but not before the XML decalaration. See previous error message.

 

 

XML document structures must start and end within the same entity.

Cause: This message can occur when the closing <html> tag is missing

Solution: Make sure there is a closing </html> tag at the end of your document

 

 

The element type “<abc>” must be terminated by the matching end-tag “</abc>”

Cause: This might occur when tags are not properly nested, or of the name of closing tag has been mispelled.

Solution: Check that your tags are correctly nested and closed properly.

 

 

The processing instruction must begin with the name of the target.

Cause: A possible cause of this message is where the the XML declaration is incorrect, for example where extra spaces have been inserted

Solution: Ensure the XML declaration and any processing instructions (lines beginning have been properly stated e.g.

Incorrect:

 

Correct:

Open quote is expected for attribute “attr” associated with an element type “element”.

Cause: This message is genereated when an attribute value is specified without enclosing it in quotes

Solution: Make sure that all attributes are enclosed in quotes (either single or double quotes will do). For example, if the error message is:

Open quote is expected for attribute "rel" associated with an element type "link".

then you should locate the offending occurence of the rel attribute within the link tag, and place quotes around its value:

Incorrect:

<link rel=stylesheet href="style.css" type="text/css">

 

Correct:

<link rel="stylesheet" href="style.css" type="text/css">

 

13 Comments

  • Jarazu says:

    I need help with this section. I can’t understand whats going on. With my site.
    Jaarzu
    Love Gadgets
    at MobiRadi.Mobi

  • Jarazu says:

    I need help with my Mobi Site it seems like theres a problem with go daddy.com I found 2 fails XHTML Mobile Profile and Valid Markup. I haven’t even put my web banner on the site yet. Im trying to figure out where the Script would be or how do I edit the Source Code. I been trying to fix this for Months Now. I really need to Launch my site. Go daddy is not a good company to get a dotMobi.
    Jaarzu
    Love Gadgets
    at MobiRadi.Mobi

  • Jarazu says:

    I got a 4 on mobiReady tester page result site and I just have little writing on my mobi site. I don’t understand need help Thanks.
    Jaarzu
    Love Gadgets
    at MobiRadi.Mobi

  • miex06 says:

    Hi, I’ve been going crazy trying to figure out why I get Invalid Markup and XHTML Mobile Profile errors. I have no specific code errors and I validate fine on W3C’s MobileOK. I’m even using the DOCTYPE declaration example from W3C.

    Here’s what I get:
    FAIL near line -1 column -1
    Your page does not validate against XHTML Basic 1.1 or XHTML Mobile Profile 1.2

    The site is an adult site so I won’t post it up here, but is there any way I can help on this I don’t see any issue on my end so this is very confusing.

    Much appreciated.

  • miex06 says:

    Just to update my last post. I figured it out. I changed DOCTYPE from XHTML MP 1.2 to Basic XHTML. after alot of research it turns out there are problems validating DOCTYPES that point to openmobilealliance.org. This really sucks as I wanted to use the MP version however I will stick to Basic XHTML doctype since it gives me a nice 5.

    So to summarize. If you are using the following DOCTYPEs they will not validate properly with ready.mobi:
    [code]

    [/code]

    You may try using XHTML Basic DOCTYPE instead for now.

  • alishag229 says:

    hi guys im very very new to XML and DTD’s im trying to work through a work sheet and i have to validate my XML file which includes an internal DTD

    the worksheet wanted me to create a DTD and should assume that all occurring attributes are mandatory, have i done this right? and can you please help me fix the error thank you

    below is the validation error what does this mean:

    1 ERROR FOUND:

    26: 14 The content of element type “teaching” must match “(course)”.

    XML document:
    [code]
    1
    2
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17 ]>
    18
    19
    20
    21
    22 XML and the Web
    23
    24 Web Server Architectures
    25

    26

    27
    28 The application of Web protocols to Biology
    29

    30

    31

    32

    [/code]

Exclusive tips, how-tos, news and comment

Receive monthly updates on the world of mobile dev.

Other Products

Market leading device intelligence for the web, app and MNO ecosystems
DeviceAtlas - Device Intelligence

Real-time identification of fraudulent and misrepresented traffic
DeviceAssure - Device Verification

A free tool for developers, designers and marketers to test website performance
mobiReady - Evaluate your websites’ mobile readiness

© 2024 DeviceAtlas Limited. All rights reserved.

This is a website of DeviceAtlas Limited, a private company limited by shares, incorporated and registered in the Republic of Ireland with registered number 398040 and registered office at 6th Floor, 2 Grand Canal Square, Dublin 2, Ireland