Names and namespaces
NCName
A non-colonised name: an XML name with no colon in it, which is what a namespace prefix and a local name each have to be.
The rules are the ones every XML name follows — start with a letter or underscore, continue with letters, digits, hyphens, full stops, underscores and a few combining characters — plus one extra prohibition: no colon anywhere. The colon is reserved for separating the two NCNames a QName is made of.
It is also the type of an xs:ID, of an XSLT variable name and of a processing instruction target, so the same restriction turns up in places that have nothing to do with namespaces.
- Defined in
- Namespaces in XML 1.0 §4
- Category
- Names and namespaces
- Also written
- non-colonised name, local name
Shown, not asserted
All 3 claims are executed on every test run, against the same engines the tools use. If the behaviour changes, the test fails rather than this page quietly becoming wrong.
A name starting with a digit is not an NCName.
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:NCName"/> </xs:schema>value 1abcWhat the engine returns
Invalid asxs:NCName.Neither is one containing a colon — that is the whole point of the type.
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:NCName"/> </xs:schema>value a:bWhat the engine returns
Invalid asxs:NCName.Hyphens, full stops and underscores are all fine inside one.
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:NCName"/> </xs:schema>value order-line_2.aWhat the engine returns
Valid asxs:NCName.
What catches people out
- Names cannot start with a digit, a hyphen or a full stop. "2026-report" is not a legal element name.
- xs:Name does allow a colon, so a value that fails as an NCName may still pass as a Name.
- The prohibition is on the character, not on the meaning: a prefix-looking string is rejected even where no namespaces are in play.
Where it bites
A definition on its own is trivia. These are the pages where this term decides whether a document works.
- Datatypesxs:NCNameThe datatype page, with more literals put through the validator.
- Datatypesxs:NameThe looser type that does permit a colon.
- Parse errorsInvalid element nameWhat a parser says when an element name breaks these rules.
Related terms
- QNameA qualified name: an optional namespace prefix, a colon, and a local name — the form every element and attribute name takes in a namespaced document.
- NMTOKENA name token: any string of XML name characters, with no restriction on what it starts with.
- Namespace prefixThe short NCName bound to a namespace URI by an xmlns:prefix declaration, used before a colon to qualify names.
- ElementThe unit of structure in XML: a start tag, its content, and a matching end tag — or a single self-closing tag when there is no content.
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.