The Word "Namespace"


No official status. Just some thoughts. See related writings.

Basic Definition

A namespace is a collection of objects ("names") which has an associated mapping from its names to other objects. It is very similar to "scope" and "context" but is more precise: an expression in two different contexts may parse completely differently; an expression in two different namespaces may have different meanings, but will parse the same unless parsing depends on the meanings.

In this example, the associated name-to-object mapping is not used:

The dot-com namespace is getting pretty full
But in this example it is:
"whitehouse" means something very different in the dot-com namespace than it does in dot-gov.

Cardinality Issues

If the mapping is many-to-many, then each name may be mapped to several objects; we could say the namespace allows for ambiguous names or that names are "overloaded". English is like this. C++ function names are like this; the ambiguity can often be resolved by matching type signatures.

The distinction between many-to-one and one-to-one mappings can be fairly subtle. The use of definite or indefinite articles ("the" and "a" respectively) can be a clue. If there's no article at all, it's probably one-to-one.

delete the file named "foo" (there is one such file)
delete a file named "foo" (there is one or more)
delete "foo" (there is exactly one)

The mapping from URIs to XML namespaces is defined to be one-to-one, so people freely use the above abreviation structure and refer to the namespace by its URI:

The XHTML namespace name is
The XHTML namespace is

Naming XML Namespaces With URIs

I think some of the confusion about XML namespaces comes from the fact that the mapping from URIs to XML namespaces is not necessarily the same as the mapping from URIs to resources. It is unclear to me whether something can be both an HTTP resource ("a network data object or service") and an XML namespace ("a collection of names which has an associated mapping"). I tend to think not. The desired operations may be quite different.

People are used to knowing that URIs are in exactly one namespace. That's the great thing about them: if you see scratched on a rock in Egypt, you know it's meant to be a web address, and your web browser can do something useful with it. In fact there's far more redundancy in that syntax than people ever need. For people, just ending in ".com" is enough most of the time. I think it's an open question whether just having an embedded dot is enough. Will people recognize as a web address?

Now XML Namespaces come along and say "we're making a mapping from strings to abstract-namespace-objects, and our strings are going to use the same syntax as URIs". That means I can no longer assume the carvings in egypt were meant as a web address.

It's not all that bad, of course. Having parallel namespaces with with URI syntax is okay as long as they are semantically parallel, and the browser's mapping is a superset of the others. If you use a URI-syntax string U as a name in any mapping (call that mapping X) you should make sure U will also work in a browser. If U denotes a resource in X, however, you can't just retreive it, because it's a different resource than a browser would get (using mapping B). If it were not different, you could have just used mapping B in the first place.

So how do you fetch X(U) when only B is implemented by the web infrastructure?

  1. Retreive U; look through the document for a new URI (U2) where you can fetch X(U). This is the RDDL approach, I believe.

  2. Map X to a media-type, and ask for U in that media type only. Unfortunately, the media-type namespace administration makes this difficult.

  3. Algorithmically combine X and U to make U2. If X needs to scale, U2 should probably have the same scheme and authority as U, but it might have a different hostname ( instead of or any of a variety of combinations of path and query structures.


       if ($U =~ m;^(http://[^/]+/)(.*)$;) {
         $U2 = $1 . "namespace-branch?name=" . CGI::escape($U)
                  . "&namespace=" . CGI::escape($X);
       } else
          # namespace branching not defined here...
I'm not convinced it's a good idea to use HTTP URIs to identify things a browser can't use. There are other ways to make unique identifiers and other ways to link those identifiers to documentation, schemas, and other related resources.

Sandro Hawke
$Date: 2001/03/23 19:17:21 $