Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does an namespace in XML specify http:?

Tags:

xml

wcf

Please clear up something for me. I'm learning WCF and see a ServiceContractAttribute parameterized with Namespace = "http://www.mywebsite.com/andsoforth"

I read in another question that Namespaces are unique opaque keys. Instead of using GUIDs they are often URLs because legitimate ones are guaranteed unique.

Why is the "http:" scheme specified with a namespace URL? Why not just the URL?

Thanks for clarifying this.

like image 930
Max Yaffe Avatar asked Nov 19 '11 22:11

Max Yaffe


1 Answers

Specifying the protocol, practically always http://, as part of the namespace URI is just a convention, and a bad one at that. (Check the threads from July 2009 on XML-DEV to see some discussion of how XML namespaces are badly botched on various accounts, including the (fixable) convention of using URLs (instead of URNs) as URIs. Key XML people themselves are admitting XML namespaces are badly botched, but what can you do? They're here to stay.)

Why are HTTP URLs such a bad choice? Protocol colon double slash lots of letters slash directory more slashes and directory and now a final slash or rather not? Because one trailing slash does make a difference.

What should it have been like? Well, DNS, or Java namespaces. Does the job without confusing people.

Here's a practical recommendation. Make your life easier by choosing easy namespaces. Take a look at URNs, they're pretty close to DNS and Java.

like image 80
Lumi Avatar answered Sep 18 '22 04:09

Lumi