XML technologies / XML / XML in a Nutshell / XML basics / XML names

(Excerpt from "XML in a Nutshell" by Elliotte Rusty Harold & W. Scott Means)

The XML specification is sometimes overly precise and fussy, yet it tries to be efficient wherever possible. One approach is to reuse rules for different things. For example, XML element names follow the same rules as attribute names and several less common constructs. These are collectively called XML names.

Element names and other XML names may contain essentially any alphanumeric character, including the usual English letters A through Z and a through z and digits 0 through 9. They may also include non-English letters, numbers, and ideographs such as ö, ç, Ω, and 串. Three punctuation characters are also allowed:

Other punctuation, such as quotation marks, apostrophes, dollar signs, parentheses, percent signs, and semicolons, is forbidden in XML names. The colon is allowed, but reserved for Namespaces as discussed in Namespaces. XML names must not contain whitespace of any kind: ordinary spaces, carriage returns, line feeds, nonbreaking spaces, or similar characters. Furthermore, all names containing the letter sequence XML in any combination of uppercase and lowercase are reserved for standardizing XML-related W3C specifications.

Note: The main new feature in XML 1.1 is that XML names may contain characters first defined in Unicode 3.0 or later. XML 1.0 is limited to characters defined in Unicode 2.0. Additional scripts allowed in XML 1.1 names include Burmese, Mongolian, Thaana, Khmer, Yi, and Amharic. (All these scripts are already allowed in XML 1.0 text content; they just cannot name elements, attributes, or Entities.) For developers who do not need these scripts in markup, XML 1.1 offers little or no benefit.
XML 1.1 also allows unusual symbols in names, such as the musical symbol for a six-string fretboard, and about a million code points not currently assigned to any character. Using these would be unwise. Even in XML 1.1, we strongly recommend restricting names to letters, digits, ideographs, and the explicitly allowed ASCII punctuation.

XML names must begin with a letter, ideograph, or underscore, never a digit, hyphen, or period. Element names and other XML names have no length limit. Thus, the following elements are all well-formed:

These elements are not allowed:

  

 

 

 

back to top