Why do XML Namespaces usually start with http://...?

The W3C Document defining XML Namespaces says (quoting) :

Definition: An XML namespace is identified by a URI reference [RFC3986]

And RFC 3986 says (quoting) :

1.1.1. Generic Syntax

Each URI begins with a scheme name, as defined in Section 3.1, that
refers to a specification for assigning identifiers within that
scheme.

So I guess using http:// is what's closest to the standard -- as HTTP is the most common scheme used on the net.

In addition, as there can be only one owner for a domain name, it allows each company to use it's URL in its namespaces.


Namespaces doesn't have any meaning in their value, except for that value to be unique to avoid nameclashing. This is why you see a lot of companies putting in the URL for their own website as the namespace. URLs serve the same purpose, to be unique. Over the years it's just become good practice to use an URL, because if everyone does that, no nameclashing should occur :)


Another common way instead of using a URL starting with http:// is to use a Uniform Resource Name whose format is defined by RFC2141.

Such namespace identifiers are e.g. used by ODF (OpenDocument Format):

urn:oasis:names:tc:opendocument:xmlns:office:1.0
urn:oasis:names:tc:opendocument:xmlns:style:1.0
urn:oasis:names:tc:opendocument:xmlns:text:1.0

Tags:

Xml

Wpf