xml Namespaces

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!


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.

Got any xml Question?