What Is a Namespace?
A namespace is a set of names in which all names are unique. For example, the names of my children could be thought of as a namespace, as could the names of California corporations, the names of C++ type identifiers, or the names of Internet domains. Any logically related set of names in which each name must be unique is a namespace.
Namespaces make it easier to come up with unique names. Imagine how hard it would be to name your next child if the name had to be unique across the face of the earth. Restricting uniqueness to a more limited context, like my set of children, simplifies things tremendously. When I name my next child, my only consideration is that I don’t use the same name that I already used for one of my other children. Another set of parents can choose the same name I choose for one of their children, but those names will be part of distinct namespaces and, therefore, can be easily distinguished.
Before a new name is added to a namespace, a namespace authority must ensure that the new name doesn’t already exist in the namespace. In some scenarios this is trivial as it is in child naming. In others it’s quite complex. Today’s many Internet naming authorities present a good example. If this step is skipped, however, duplicate names will eventually corrupt the namespace, making it impossible to refer to certain names without ambiguity. When this happens, the set of names is no longer officially considered a namespace—by definition a namespace must ensure the uniqueness of its members.
This XML carries HTML table information:
<tr>
<td>Apples</td>
<td>Bananas</td>
</tr>
</table>
This XML carries information about a table (a piece of furniture):
<name>African Coffee Table</name>
<width>80</width>
<length>120</length>
</table>