Element and attribute names in XML are called QNames (qualified names).

A QName is made of:

  • a namespace (a URI)
  • a prefix (an NCName, NC because it contains no colon)
  • a local name (an NCName)

Only the namespace and the local name are relevant for comparing two QNames. The prefix is only a proxy to the namespace.

The namespace and prefix are optional, but the namespace is always present if the prefix is present (this is ensured at the syntactic level, so this cannot be done wrong).

The lexical representation of a QName is prefix:local-name. The namespace is bound separately using the special xmlns:... attributes (reminder: attributes beginning with xml are reserved in XML).

If the prefix is empty, no colon is used in the lexical representation of the QName, which only contains the local-name. QNames with an empty prefix either have no namespace (if no default namespace is in scope) or are in the default namespace.