The XML language syntax

Watch those capitals - XML is very particular

HTML does not mind if you use <p> and then follow with </P>, the result will be the same because case-sensitive tags are not a problem in HTML. XML is completely case-sensitive. The above example will cause an XML error.

XML errors are also different from HTML - an error in the actual XML code in an XML page will cause the page to simply not load. You'll get a message saying where the error was found (albeit a little cryptically sometimes) and nothing more will happen. Whereas an error on a HTML page may simply stop the Javascript from operating, leaving the page itself still displayed, an XML error prevents anything being displayed except the error.

The most common error is case. Every tag must match the definition and the template. If you define a custom tag as <MyTag> in the stylesheet (.xsl file) and then use <MYTAG> in the XML file, you will be shown the error. Reduce this error to a minimum by only using CAPITALS for all tags.

The next error affects closing tags. If you are in the habit of encoding HTML paragraphs as TEXT<p> instead of <p>TEXT</p> then you will be in for a lot of work correcting your converted XML. Netscape already has problems implementing CSS in pages where the closing tag </p> is not used. Tags that do not have a closing tag defined by HTML (like <meta> and <br> must be expressly coded as such in the XML by adding a / to the tag as follows: <br/>.

Finally, XML even requires ordinary HTML tags to become case-sensitive. Opening HTML tags used in the stylesheet must match the corresponding closing tag. This can be one of the hardest errors to correct. Consider:

<li>list item</LI>

This causes TWO XML errors - the UL does not match ul and the li does not match LI. Note the use of the </li> tag that is otherwise optional in HTML.

A final error concerns the use of <, >, ", ', & characters. These have special significance in a lot of web based languages and you need to use the coded versions to prevent mysterious errors.

For < use &lt;
For > use &gt;
For & use &amp;
For " use &quot;
For ' use &apos;

This is part of Copyright © 1998-2004 Neil Williams
See the file about.html for copying conditions.