Skip to main content

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

Namespaces guide

XML namespace prefix vs URI

Understand why prefixes are replaceable aliases, why namespace URIs are compared literally, and how expanded names keep documents interoperable.

7 min read · Updated 2026-08-21

The short answer

An XML namespace prefix is a document-local alias; the namespace URI is the identity. Two elements with different prefixes have the same expanded name when their prefixes bind to the same URI, while identical prefixes in different documents can name unrelated vocabularies.

Compare expanded names rather than spellings

Processors identify a namespaced element by namespace URI plus local name. The prefix makes source readable and connects a qualified name to a declaration, but applications must not treat the chosen letters as the vocabulary identity.

Two prefixes, one expanded name
<root xmlns:a="urn:example:catalog" xmlns:cat="urn:example:catalog">
  <a:item/><cat:item/>
</root>

Treat namespace URIs as exact identifiers

Namespace names are compared as strings. Changing http to https, adding a slash, changing case, or following a redirect produces a different name even when the URI looks related or resolves to the same page.

  • Copy the namespace URI from the governing specification.
  • Do not normalize schemes, slashes, or letter case.
  • Do not require a namespace URI to return a document when fetched.
  • Preserve unfamiliar namespace declarations during transformations.

Bind your own prefixes in XPath and XSLT

An XPath prefix is resolved from the evaluator's namespace map, not copied automatically from the source document. You may bind any convenient prefix to the correct URI and use it consistently in the expression.

Default namespaces apply to element names in XML source but not to unprefixed XPath 1.0 name tests, which is why a visible unprefixed element may still require a prefix in the query.

Primary sources

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.