A Ten-Minute Guide to XML Namespaces
Let’s examine the motivations behind XML namespaces. The first motivation is to have namespaces replace the formal public identifier (FPI), an inheritance from SGML. These identifiers provide a way to identify which vocabulary , or set of names, is being used in a document. The XML/SGML way of identifying the vocabulary used in our library would be to add a public identifier to the document type declaration such as:
<?xml version="1.0"?> <!DOCTYPE library PUBLIC "-//ERICVANDERVLIST//DTD for library//EN" "library.dtd"/> <library> ... </library>
This DOCTYPE declaration contains an FPI
(-//ERICVANDERVLIST//DTD for
library//EN) and the location of the DTD
describing the vocabulary (library.dtd). XML
requires that the DOCTYPE
declaration always provide a
SYSTEM
identifier—a
location—when a
PUBLIC
identifier is used, though
PUBLIC identifiers aren’t
required when SYSTEM identifiers are used. The
creators of XML 1.0 didn’t want to require parsers
to include the tools (typically XML catalog processing) for resolving
formal public identifiers to addresses, but they kept the option
open. Because the DOCTYPE declaration provides the
parser with identification of the DTD rather than the identification
of the abstract set of names, this approach is generally sensible.
The first goal of XML namespaces is to provide identifiers for the abstract notions of vocabularies and namespaces without linking these identifiers directly to the technical implementations ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access