Namespace

XML is the eXtensible Markup Language which provides a simple syntax to distinguish tags from the text they markup. <tag>text</tag>. It’s extensible so that you can use just about any tags you care to name, as long as they are nested correctly. For example, <Name><given>Jane</given><family>Doe</family></Name>; but not <b>my <i>emphatic</b> style</i>.

There are lots of sets of tags. What if we want to use tags from different sets with the same name ? Easy, we add a prefix to the tags. eg. <my:tag/> vs <your:tag/>. For consistency, we also link the prefix to an identifier of a resource which defines the tags. Often we use a web address, a URL like http://www.w3.org/2001/XMLSchema to locate the resource. Sometimes we use a resource name like urn:iso:std:iso:20022 which is independent of location. This matters when the protocol, host or directory changes.
eg. the above resource is now served via https, in preference to http.

As we can use several prefixes linked to the same identifier, namespace-aware apps query and compare EQNames instead of QNames.
A tag with a prefix is a qualified name (QName). eg. xsd:string
When the prefix is replaced by the identifier, it is an expanded qualified name (EQName), written as Q{http://www.w3.org/2001/XMLSchema}string.
The Q{} is a writing convention of XPath, to markup the identifier; it is not part of the EQName which comprises only the identifier and the tag.

There has been a tradition in XML of writing the identifier without a trailing separator, leaving that to be added by user choice in a given context.

By comparison, in the Resource Description Framework (RDF) simply replaces the prefix which includes the colon : , with the identifier in place.
So there is a tradition of including trailing separators.

We recommend that trailing separators are included in namespace identifiers for both RDF and XML, in order to support simple string joins to flexibly identify the whole or component parts.

  • Namespace URNs should end in a colon : .
  • Namespace URLs should end in a slash / .

Both of these allow the user to choose :

  • hash # to identify a fragment as part of the whole, or
  • without the hash to select just the part of the whole.

For example, if adopted and implemented:
http://www.w3.org/2001/XMLSchema/
would fetch the whole vocabulary;
http://www.w3.org/2001/XMLSchema/#string
would fetch the whole vocabulary, and show string’s definition;
http://www.w3.org/2001/XMLSchema/string
would fetch just string’s definition.