XML allowable characters

Viewed 50

At a high-level, what do the following character codes add support for in XML?

[#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | 
[#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | 
[#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]

Ref: https://www.w3.org/TR/xml/#NT-NameStartChar

I can look up the various characters, for example:

À   latin capital letter a with grave   0300    192 0xC0    À

But I'm wondering if someone could explain, at a high level what this allows for -- and doesn't allow for -- since there are gaps between the ranges (for example, 0xF7).

1 Answers

The rationale behind the naming rules is summarized on the same linked page.

The first character of a Name must be a NameStartChar, and any other characters must be NameChars; this mechanism is used to prevent names from beginning with European (ASCII) digits or with basic combining characters.

Almost all characters are permitted in names, except those which either are or reasonably could be used as delimiters.

The ASCII symbols and punctuation marks, along with a fairly large group of Unicode symbol characters, are excluded from names because they are more useful as delimiters in contexts where XML names are used outside XML documents

For example, checking the list of Unicode blocks finds that x300-x36F are Combining Diacritical Marks, and x2190-x21FF are Arrows, which explains why both ranges are excluded from the quoted list.

More specifically, the section on Character Classes describes the name rules in terms of Unicode Categories (with some exceptions and clarifications noted separately, not copied below).

  • Name start characters must have one of the categories Ll, Lu, Lo, Lt, Nl.

    • Ll  -  Letter, uppercase
    • Lu  -  Letter, lowercase
    • Lo  -  Letter, other (an ideograph or a letter in a unicase alphabet)
    • Lt  -  Letter, titlecase (ligatures containing uppercase followed by lowercase)
    • Nl  -  Number, letter (numerals composed of letters or letterlike symbols)
  • Name characters other than Name-start characters must have one of the categories Mc, Me, Mn, Lm, or Nd.

    • Mc  -  Mark, spacing combining
    • Me  -  Mark, enclosing
    • Mn  -  Mark, nonspacing
    • Lm  -  Letter, modifier (incl. diacritics)
    • Nd  -  Number, decimal digit
Related