xs:ID — Definition of unique identifiers.

Derived from:




Known subtypes:



xs:enumeration, xs:length, xs:maxLength, xs:minLength, xs:pattern, xs:whiteSpace

<xs:simpleType name="ID" id="ID">
  <xs:restriction base="xs:NCName"/>


The purpose of the xs:ID datatype is to define unique identifiers that are global to a document and emulate the ID attribute type available in the XML DTDs.

Unlike their DTD counterparts, W3C XML Schema ID datatypes can be used to define not only attributes, but also simple element content.

For both attributes and simple element content, the lexical domain of these datatypes is the lexical domain of XML nonqualified names (xs:NCName).

Identifiers defined using this datatype are global to a document and provide a way to uniquely identify their containing element, whatever its type and name is.

The constraint added by this datatype beyond the xs:NCName datatype from which it is derived is that the values of all the attributes and elements that have an ID datatype in a document must be unique.


Applications that need to maintain a level of compatibility with DTDs should not use this datatype for elements but should reserve it for attributes.

The lexical domain (xs:NCName) of this datatype doesn’t allow the definition of numerical identifiers or identifiers containing whitespaces.

W3C XML Schema provides another mechanism to define unique and key constraints using the xs:unique or xs:key ...

Get XML Schema now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.