• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XML namespace - what is purpose?

 
Ranch Hand
Posts: 1609
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Alas, poor Yorick, he knew this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic