Question

A XML namespace should be a URI, but it can use any URI scheme, including those that are not URLs.

Then why do all widely used XML namespaces use the http scheme (e.g. http://www.w3.org/XML/1998/namespace), considering that trying to use the URI as an URL by retrieving that document using the HTTP protocol is not guaranteed to do anything useful (and often doesn't)?

I understand the usefulness of DNS domains in namespace names to help guarantee uniqueness. But that doesn't require the http scheme, there could be a separate scheme for that (something like namespace:w3.org/XML/1998/namespace). This would avoid the confusion between URIs and URLs, while maintaining domain-based uniqueness.

Was it helpful?

Solution

W3C explains their reasoning for using http URIs in the article URNs, Namespaces and Registries. It specifically discusses XML namespaces and a proposed scheme very similar to namespace mentioned in the question.

According to the article, the big advantage of using http is that retrieving the document pointed to by the URI can work and it can provide useful information to both humans and machines.

OTHER TIPS

In most cases, I think that it's "because we've always done it that way." If you look at the Namespace spec you'll see that the examples all use HTTP URLs, but do not give a reason.

On the other hand, if you have control over your public-facing web-service, it can be very useful to actually put documentation at the namespace URL. For example, any of the Spring namespaces (eg: http://www.springframework.org/schema/beans/) take you to a page that contains the relevant XML schema documents for each version.

Personally, I prefer using namespaces that begin with urn:x-, followed by the domain name of whatever company I'm working for. That makes it very clear that this is a namespace, and has no other meaning.

Licensed under: CC-BY-SA with attribution
scroll top