Name

Names

Synopsis

XML 1.0 names must adhere to the following lexical conventions:

  • Begin with a letter, ideograph, _, or : character.

  • After the first character, be composed only of letters, digits, ., -, _, and : characters.

In this context, a letter is any Unicode character that matches the Letter production from the XML 1.0 EBNF grammar at the end of this chapter.

Tip

See the XML 1.1 EBNF grammar production for Name to see which characters are permitted within XML 1.1 names.

According to the XML 1.0 specification, the : character may be used freely within names, although the character is now officially reserved as part of the “Namespaces in XML” recommendation. Even if a document does not use namespaces, the colon should still not be used within identifiers to maintain compatibility with namespace-aware parsers. See the Section 21.3.4 in this chapter for more information about how namespace-aware identifiers are formed.

Names should also avoid starting with the three-letter sequence X, M, L (in any case combination), unless specifically sanctioned by an XML specification.

Get XML in a Nutshell, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.