Skip to main content
XMLDir

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

XSD datatype

xs:Name

An XML name, which may contain a colon. Rarely the type you want — NCName usually is.

xs:Name permits the colon that xs:NCName forbids, because it models the raw XML name production rather than a namespace-aware one. In practice a name containing a colon is a QName, and should be typed as one.

It is worth knowing mainly to explain why some schemas accept 'a:b' where you expected a rejection.

Lexical space
Letter, underscore or colon, then name characters including colons.
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.

  • order
  • soap:Envelope
  • _private
  • a:b:c

What does not

  • 1st

    Cannot start with a digit.

  • has space

    Whitespace is not a name character.

What catches people out

  • 'a:b:c' is a valid xs:Name and not a valid QName. Name checks characters, not structure.
  • Prefer xs:NCName or xs:QName; xs:Name accepts things neither of them would.

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:Name"/>
</xs:schema>

Open the XSD validator

Related

All 29 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.