<mediacollection xmlns:mov="http://www.xyz.com/ns/movies">
The ns
in the namespace name http://www.xyz.com/ns/movies stands for "namespace" and is often used in URL namespace names. It isn't a necessity but it's not a bad idea in terms of being able to quickly identify namespaces. If you don't want to use a URI as the basis for a namespace name, you could also use the URN (Universal Resource Name) of a web resource to guarantee uniqueness. URNs are slightly different from URLs and define a unique location-independent name for a resource that maps to one or more URLs. Following is an example of using a URN to specify a namespace for my web site:
<mediacollection xmlns:mov="urn:xyz.com:ns:movies">
Making Sense of URLs, URNs, and URIsThere is often confusion among XML developers regarding the relationship between URLs, URNs, and URIs. Perhaps the most important distinction to make is that URIs encompass both URLs and URNs. URNs differ from URLs in that URLs describe the physical location of a particular resource, whereas URNs define a unique location-independent name for a resource that maps to one or more URLs. An easy way to distinguish between URLs and URNs is to examine their names: URLs all begin with an Internet service prefix such as |
Keep in mind that a namespace doesn't actually point to a physical resource, even if its URI does. In other words, the only reason namespaces are named after URIs is because URIs are guaranteed to be uniquethey could just as easily be named after social security numbers. This means that within a domain name you can create URIs that don't actually reference physical resources. So, although there may not be a directory named pets
on my web server, I can still use a URI named http://www.xyz.com/ns/pets to name a namespace. The significance is that the xyz.com domain name is mine and is therefore guaranteed to be unique. This is important because it allows you to organize XML documents based upon their respective namespaces while guaranteeing uniqueness among the namespace names.