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:NMTOKENS

A whitespace-separated list of NMTOKEN values, with list whitespace collapsed before validation.

xs:NMTOKENS is the built-in list type whose items are xs:NMTOKEN. Runs of spaces, tabs and line breaks are collapsed, then each remaining token is validated independently.

The XSD 1.0 datatype is derived with minLength 1, but the libxml2 validator used here accepts an empty element for the built-in type. Add an explicit minLength facet when an empty list must be rejected consistently.

Lexical space
One or more NMTOKEN values separated by XML whitespace.
Derives from
xs:anySimpleType
Category
String types
Facets
length, minLength, maxLength, 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.

  • one
  • one two
  • alpha-1 beta.2
  • one two
  • (the empty string)

What does not

  • one a/b

    The second item contains a slash, which is not a name character.

  • one,two

    A comma is not a list separator or a name character.

What catches people out

  • length counts list items, not characters. Add minLength explicitly when empty input must fail across processors.
  • Commas are not separators. This is an XML-whitespace-separated list.
  • Whitespace is always collapsed for list types and cannot be changed by derivation.

The schema used

This is the exact schema the literals above are validated against. Paste it into the validator with one of them to see the result yourself.

schema.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="v" type="xs:NMTOKENS"/>
</xs:schema>

Open the XSD validator

Related

All 39 datatypes and facets

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.