- Why Namespaces Are Needed: Resolving Name Conflicts
- Qualified Names, Prefixes, Local Names, and Other Terminology
- Declaring Namespaces in XML Documents
- Default Namespace
- Handling Namespaces in a DTD or XML Schema
- Validating Documents with Namespaces
- What Does a Namespace Point To?
- Namespace Support and Use
- Special Attributes: xmlns, xml:space, xml:lang, and xml:base
- Common Namespaces
- Summary
- For Further Exploration
Summary
In this chapter, we learned about Namespaces in XML, XML Information Set, and Canonical XML, three specifications that at least at one time were the work of the W3C XML Core Working Group. All three of these specifications followed the XML 1.0 Recommendation, attempting to address particular areas that are fundamental. The main points covered are:
XML namespaces are necessary to resolve element (or attribute) name conflict when a document refers to multiple vocabularies (DTDs or XML Schema).
Namespaces are useful to understand because many specifications depend on them for one reason or another, such as XSLT, XML Schema, and XLink.
A universal name (or qualified name) consists of a prefix and a local name, separated by a colon.
A prefix is just shorthand for the actual namespace name, which is represented by a URI.
A namespace declaration appears in an XML document, rather than the DTD. This declaration associates the prefix with the namespace name (URI).
Prefixes are added to elements or attributes in the XML document, except if a default namespace is used.
Namespace scope applies to the element that declares the namespace and all its descendants.
Although namespaces cannot be declared in DTDs, you do need to declare the URI as a fixed value for an xmlns attribute.
Validation and XML namespaces are two different concepts. Creating valid documents that correctly use XML namespaces can be tricky.
A namespace need not point to any physical resource at all, although many do. What the namespace URI maps to is completely undefined. RDDL is a possible way to provide a flexible solution to this ill-defined endpoint.
Special attributes xmlns, xml:space, xml:lang, and xml:base are discussed.
A table of common namespace names, their conventional prefixes, and the specifications with which they are associated is presented.