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


One attribute—the xml:lang attribute—is reserved for XML’s own use. This attribute is reserved to identify the human language in which the element is written. The value of the attribute is one of the ISO 639 country codes; some of the most common language codes are shown in Table 12.5.

Table 12.5 Common ISO 639 Language Codes

Code Language

ar Arabic
ch Chinese
de German
en English
es Spanish
fr French
gr Greek
it Italian
ja Japanese
nl Dutch
pt Portugese
ru Russian

Optionally (where several versions of the language exist, such as British and American English), the language code can be followed by a hyphen (-) and one of the ISO 3166 country codes. Some of the most common country codes are shown in Table 12.6; if you have spent much time on the Internet, you may recognize these as the same codes that are used in email addresses and URLs. An element written in American English could then be identified like this (note the cases; the language code is in lowercase and the country code is in uppercase):

<para xml:lang=”en-US”>My country ’tis of thee.</para>
Table 12.6 Common ISO 3166 Country Codes

Code Country

AT Austria
BE Belgium
CA Canada
CN China
DE Germany
DK Denmark
EN England
ES Spain
FR France
GR Greece
IT Italy
JA Japan
NL The Netherlands
PT Portugal
RU Russia
US United States

The codes given in Tables 12.5 and 12.6 are not complete. Another coding scheme registered by the Internet Assigned Numbers Authority (IANA) is defined in RFC 1766, and if you really need to, you can devise your own language code. User-defined codes must be prefixed with the string ‘x-’, in which case you could declare an element as being in computer geek, like this:
     <para xml:lang=”x-cg”>Do you grok this code?</para>

Naming Rules

So far you have seen examples of the markup used for elements and attributes, and in each a name has been given to the XML markup element. XML has certain specific rules governing what names you can use for all its markup objects. XML’s naming rules are as follows:

  A name consists of at least one letter: a to z, or A to Z.
  If the name consists of more than one character, it may then start with an underscore (_) or a colon (:).
  The initial letter (or underscore) can be followed by one or more letters, digits, hyphens, underscores, full stops, and so-called combining characters, extender characters and ignorable characters. (These last three classes of character are taken from the Unicode character set and include some of the special Unicode character symbols and accents. For more information about Unicode, you can look up http://www.unicode.org/.)

Note that spaces and tabs are not allowed in element names (<one two> would be interpreted as two separate names), and the only two punctuation signs allowed are the hyphen (-) and the period or full stop (.).

No rule requires that your choice of a name should make sense. As long as you obey the naming rules, you can call XML objects whatever you like, and the names can be as long and as meaningless as you like. However, it is worth remembering that one of the major benefits of using XML in the first place is that it is self describing. If you are using elements such as <thingamajig>, <whatsit>, and <doohickey>, you will be defeating one of the major purposes of XML. Try to choose names that are suggestive of the nature or purpose of the object.


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.