Skip to main content
XMLDir

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

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
    1abc

    What the engine returns

    Invalid as xs: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:b

    What the engine returns

    Invalid as xs: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.a

    What the engine returns

    Valid as xs: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.

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.