home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Platinum Edition Using HTML 4, XML, and Java 1.2
(Publisher: Macmillan Computer Publishing)
Author(s): Eric Ladd
ISBN: 078971759x
Publication Date: 11/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next


Comments

No self-respecting language, whether it’s a programming language or a markup language, could hold its head up without enabling comments to be added to the code. From a maintenance point of view, it is also pretty important that you should have some lasting record of why you did particular things. The best way to document your code is to include the explanation with the code by means of comments.

In keeping with the design constraint of keeping XML simple, its comment facilities are also simple.

Comments have the form

<!-- this is comment text -->


CAUTION:  

The comment start tag (<!--) and end tag (-->) must be used exactly as they are shown here; inserting spaces or any other characters into these strings can lead to the tags—or anything inside the comment—being mistakenly interpreted by the XML processor as markup.


Provided that you use the comment start tag and end tag correctly, everything in the comment text will be completely ignored by the XML processor. The following comment, therefore, is quite valid:

<!-- These are the declarations for the <title> and <body> -->

Only one restriction exists on what you can place in your comment text: The string -- is not allowed (this keeps XML backward compatible with SGML). (The string --> will end the comment.)

Comments can be placed anywhere in an XML document—outside other markup. Therefore, the following is allowed:

<para>This is simple <!-- So everyone tells me --> to do.</para>

But this is not allowed:

<para <!-- blatant lie --> >This is simple to do.</para>

Character References

Unlike SGML (and as a result, HTML too), which is very much ASCII based, XML was developed right from the start with a view to supporting languages other than English. In HTML, you can enter the code for certain non-English characters. For example, e` would be &egrave;, í would be &iacute; and [???]u would be &ucirc;. As you will see at the beginning of the next chapter, these codes are, in fact, entity references. The abbreviations egrave, iacute, and ucirc are taken from the ISO 8859/1 character set (SGML’s character set), which is derived from the ISO/IEC 646 version of the ASCII alphabet (the first 128 characters). ISO 8859/1 is also the basis for the Microsoft Windows fonts. Although these character entity references will enable you to deal with most European and Scandinavian languages, they are completely insufficient for displaying many Asian or Middle Eastern languages, such as Japanese, Hindi, or Arabic.

XML solves this problem by being based on Unicode and on the even more extensive ISO/IEC 10646 standards (the latter even allows the use of Chinese characters). If you need them, XML enables you to use these exotic characters—even if your keyboard doesn’t support them. You do this by entering a character reference.

A character reference consists of the string &#, followed by the number of the character in the ISO/IEC 10646 alphabet and terminated by a semicolon (;). The character number may be either a decimal number, in which case you enter the number as is, or in hexadecimal form, in which case you must precede the number with the letter x, such as x12ABC. The character reference for the copyright symbol (©), for example (written in HTML as &copy;), is &#169; (in decimal) or &#xA9; (in hexadecimal). You can get more information on these character references at http://wwwold.dkuug.dk/jtc1/sc2/wg2/.


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.