What Is an Expanded Name in XML Namespaces?
In the XML namespace specification, an expanded name is a two-part identifier consisting of a namespace URI and a local name that together uniquely identify an XML element or attribute. While XML documents use prefix-based qualified names (QNames) for readability and brevity, processing software resolves these into expanded names to eliminate naming collisions across different vocabularies. This article explains the structure, purpose, and standard representation of expanded names in XML.
Structure of an Expanded Name
An expanded name consists strictly of two components:
- Namespace Name (URI): The Uniform Resource Identifier (URI) reference associated with the namespace. If an element or attribute does not belong to any namespace, this value is null or empty.
- Local Name: The local part of the XML element or attribute name (the portion that appears after the colon in a prefixed name, or the entire name if no prefix exists).
Unlike raw XML markup, an expanded name contains no prefix. Prefixes only serve as local placeholders within a document to map to a namespace URI.
Purpose and Functionality
In XML, different schemas might use the same local name for different
concepts (for example, <title> in a book catalog
versus <title> in an employee directory). XML
namespaces solve this ambiguity.
Because document authors can choose any arbitrary prefix (e.g.,
bk:title vs. book:title), software processors
cannot rely on the prefix to determine an element’s identity. Instead,
the XML parser resolves the prefix against the in-scope
xmlns declaration to create an expanded name. Two elements
are considered identical in identity if and only if both their namespace
URIs and local names match.
Common Notation: Clark Notation
The World Wide Web Consortium (W3C) XML Namespace specification defines the expanded name as a conceptual pair, rather than mandating a specific string serialization. However, the standard universal representation used across tools and specifications (such as XPath and XSLT) is James Clark’s notation:
{namespaceURI}localName
For example, consider this XML element:
<bk:book xmlns:bk="http://example.org/books">The QName is bk:book, and its corresponding expanded
name is:
{http://example.org/books}book
QNames vs. Expanded Names
- Qualified Name (QName): The lexical representation
used inside the XML document text (e.g.,
prefix:localPart). It is context-dependent because the prefix depends on active namespace declarations within the document tree. - Expanded Name: The resolved, context-independent
logical identity (e.g., URI +
localPart). It remains identical regardless of what prefix was used in the original document.