home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Book HomeXML in a NutshellSearch this book

2.4. XML Names

The XML specification can be quite legalistic and picky at times. Nonetheless, it tries to be efficient where possible. One way it does that is by reusing the same rules for different items where possible. For example, the rules for XML element names are also the rules for XML attribute names, as well as for the names of several less common constructs. Generally, these are referred to simply as XML names.

Element and other XML names may contain essentially any alphanumeric character. This includes the standard English letters A through Z and a through z as well as the digits 0 through 9. XML names may also include non-English letters, numbers, and ideograms such as ö, ç, Figure , and Figure . They may also include these three punctuation characters:

_
the underscore

-
the hyphen

.
the period

XML names may not contain other punctuation characters such as quotation marks, apostrophes, dollar signs, carets, percent symbols, and semicolons. The colon is allowed, but its use is reserved for namespaces as discussed in Chapter 4. XML names may not contain whitespace of any kind, whether a space, a carriage return, a line feed, a nonbreaking space, and so forth. Finally, all names beginning with the string XML (in any combination of case) are reserved for standardization in W3C XML-related specifications.

XML names may only start with letters, ideograms, and the underscore character. They may not start with a number, hyphen, or period. There is no limit to the length of an element or other XML name. Thus these are all well-formed elements:

  • <Drivers_License_Number>98 NY 32</Drivers_License_Number>

  • <month-day-year>7/23/2001</month-day-year>

  • <first_name>Alan</first_name>

  • <_4-lane>I-610</_4-lane>

  • <téléphone>011 33 91 55 27 55 27</téléphone>

  • Figure

These are not acceptable elements:

  • <Driver's_License_Number>98 NY 32</Driver's_License_Number>

  • <month/day/year>7/23/2001</month/day/year>

  • <first name>Alan</first name>

  • <4-lane>I-610</4-lane>



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.