Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML namespace - what is purpose?

 
Akhilesh Trivedi
Ranch Hand
Posts: 1599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are xml namespaces? and why is that we often use URLs in them?

I created



and opened it in IE. I did not get any complaint from the browser that http://something.com is invalid namespace or anything such.

I was expecting that I get some error stating either I have some wrong URL or my xml is not properly formed as per the URL, as I have not placed any DTD/XSD or anything on that URL.

If there is no link between the URL and the XML then what is the purpose of having XML namespace?

Also my other question is that do I need to be connected to internet for non-local URLs in namespaces?
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A namespace identifier is not an URL, it is a URI - a very important distinction! As such it does not need to be related to an actually existing domain (although that may sometimes make sense), nor can it be verified in any way by making a network call. A namespace serves to uniquely identify element names, so that it's possible to have XML documents like this:

and it's always clear which "foo" element is meant - the two may be very different in meaning!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic