Skip to main content

Search 400 pages — tools, formats, elements, namespaces, directory, comparisons, XPath, datatypes, glossary, parse errors, schema errors, use cases, guides, blog and product.

XSD datatype

xs:NMTOKEN

One XML name token: name characters without the rule that the first character must be a letter or underscore.

xs:NMTOKEN accepts the characters XML permits inside a name, including digits, hyphens, periods and colons, but it does not require a name-like first character. That is why '42' is a valid NMTOKEN and not a valid Name.

It is a lexical token rather than a namespace-aware QName. A colon carries no prefix binding requirement here.

Lexical space
One or more XML NameChar characters, with no whitespace.
Derives from
xs:token
Category
String types
Facets
length, minLength, maxLength, pattern, enumeration, whiteSpace

What validates

Every literal below is put through the schema validator on each test run, against the schema at the foot of this page.

  • section-1
  • 42
  • ns:item
  • a.b
  • _private

What does not

  • two words

    Whitespace separates tokens and is not part of one NMTOKEN.

  • (the empty string)

    At least one name character is required.

  • a/b

    A slash is not an XML name character.

What catches people out

  • A leading digit is valid here even though it is invalid for xs:Name and xs:NCName.
  • A colon has no namespace semantics in this type; use xs:QName when the prefix must resolve.
  • Whitespace is collapsed before validation, but two resulting tokens still do not make one NMTOKEN.

Get started

Bring order to the XML your team can't afford to ignore.

Create a free account and get a private workspace to search, validate, diff, and monitor your XML feeds, sitemaps, schemas, and vendor integrations.