xs:QName — Namespaces in XML qualified names.

Derived from:




Known subtypes:



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

<xs:simpleType name="QName" id="QName">
  <xs:restriction base="xs:anySimpleType">
    <xs:whiteSpace value="collapse" fixed="true"/>


The lexical space of xs:QName is the qualified names per Namespace in XML, i.e., a local name (which is a xs:NCName) with an optional prefix (itself a xs:NCName), separated by a colon (“:”), where the prefix is declared a namespace prefix in the scope of the element carrying the value. Its value space comprises the pairs (namespace URI, local name) in which the namespace URI is the URI associated to the prefix in the namespace declaration.

This dissociation between lexical and value spaces makes a lot of difference when using facets such as xs:pattern (which acts on the lexical space only and thus constrains the namespace prefix) and xs:enumeration (which acts on the value space and thus constrains the namespace URI).


It is impossible to apply a pattern on the namespace URI.

The usage of QNames in elements and attributes is controversial since it creates a dependency between the content of the document and its markup. However, the official position of the W3C doesn’t discourage this practice.


W3C XML Schema itself has already given us some examples of QNames. When we wrote "<xs:attribute name="lang" ...

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.