0

I know that this question sounds stupid.But I think I can not move ahead without understanding this. See,I understand that defining a namespace using my domain name makes it unique. But what is the necessity? How could a namespace in someone else's xml document be mixed up with mine if I don't use a unique namespace?

When someone visits my website,the browser would possibly be pointing to the xml documents in my database and so the namespaces in my document will be used.So how could someone else's namespace get mixed up with mine?

Please Help.Down vote this question if it sounds stupid but please help me. I surfed a lot before posting this on stackoverflow.But nothing helped me.

Mathews Mathai
  • 1,707
  • 13
  • 31
  • 1
    Possible duplicate of [What are XML namespaces for?](http://stackoverflow.com/questions/128389/what-are-xml-namespaces-for) –  Nov 21 '15 at 15:55
  • @Terminus Thanks a lot! – Mathews Mathai Nov 21 '15 at 16:09
  • @Matthews, as far as I can see you asked a question sometime during a Saturday (depending where you live), and half an hour later you were complaining that no-one has answered it. Not all the people capable of answering your question are online 24 hours a day, especially at weekends, and your impatience is very likely to put off anyone who comes along when they get back to the office on Monday. – Michael Kay Nov 21 '15 at 18:56
  • @MichaelKay I am so sorry.I removed that comment.It was a misconception.I heard that stackoverflow was really fast. So sorry.I meant no offence.And my conclusion was based on an earlier experience which was really bad. You might want to take a look at that. http://stackoverflow.com/questions/33565538/please-explain-me-the-mechanism-behind-this-program – Mathews Mathai Nov 21 '15 at 19:01

2 Answers2

0

Namespaces are basically just invented names adhering to the uri/urn syntax. Most everything else is just a gentleman's agreement. In particular, anyone could invent his namespace to be your domain name + some suffix that he sees fit. It is of course best practice not to do so and it would actually only make sense for the purpose of sabotaging some processing.

It might be that usurping a registered domain name corresponding to a regostered trademark might even have a legal angle but you'd have to talk to a lawyer about that.

Therefore, no central namespace register exists. Some namespaces, however, are defined as part of standards (notably the namespaces for xml vocabularies like svg, xhtml, xsd, and of course xml itself ).

collapsar
  • 17,010
  • 4
  • 35
  • 61
  • Thanks a lot! Could you be more specific on how it would effect me if someone else uses a same namespace? I mean namespace is moreover a part of the code and is not much related to what is viewable to the users or the world. So how does it matter? For example, If I name one of my javascript variables as "change",how does it matter if someone else has also named one of the variables in their script as "change"? Since the browser points to my site database,the namespace is already unique.Is it not? – Mathews Mathai Nov 21 '15 at 15:46
  • Is the namespace viewable to the users who visit my site? – Mathews Mathai Nov 21 '15 at 15:50
  • You are mixing up xml namespaces and js namespaces. JS namespace collisions typically happen only if code bases from multiple sources (i.e. different libraries) are used. A standard practice is to have a global library object anyway ( eg. `$` for jquery ) throught which all uses of library code are funnelled, so to resolve conflicts you would simply assign that toplevel object to a differently named variable and use that. – collapsar Nov 21 '15 at 15:51
  • _Everything_ you write in js for client-side execution is visible to visitors of your site. Of course, in production code you would minify your js,a process which alse serves obfuscation purposes. However,you wouldn't fool tools for reverse engineeering. – collapsar Nov 21 '15 at 15:53
  • Thanks for your effort. Suppose we both have a name space named "newnamespace" in our respective xml documents in our respective databases. How could the namespace in my database get mixed up with yours. Xml documents are in the server and it's not visible to the rest of the world and moreover when someone visits my website and clicks a link in my website,the browser would point towards a xml document in my database and how could it get mixed up with yours or manipulate your document or uniqueness of your site? – Mathews Mathai Nov 21 '15 at 15:55
  • sure it is, the namespace declarations are part of the xml document itself. I think, however, that your concerns are unjustified - nobody is really interested in provoking namespace collisions; in the improbable case that such a collision occurs, hey, its just a name so a simple search & replace fixes the issue. – collapsar Nov 21 '15 at 15:59
  • What is the effect of namespace collisions? Will it affect my site or business? – Mathews Mathai Nov 21 '15 at 16:01
  • As I said, any impact will basically be a technical one, its extent depends on the technical setting, the remedy is trivial, so I'd say it will be easy to contain the (technical and economic) effect on your site and business. Once again, there are hosts of other risks that you should be more concerned of. Namespace collision is not an issue. – collapsar Nov 21 '15 at 16:02
  • I would have upvoted your answer.But I don't have enough reputation to upvote. Thanks a lot! Your answer and comments have just encouraged me to move ahead! – Mathews Mathai Nov 21 '15 at 16:07
  • Glad that I could help. Don't worry about the upvote - thanks anyway for your intent to do that. Good luck ! – collapsar Nov 21 '15 at 16:08
0

Most of the time, if someone creates an aircraft manual using the namespace http://foo.com/, and you create a CD catalogue that also uses the namespace http://foo.com/, it's not going to matter in the slightest, any more than if two people are called Tom Jones. But one day, if one of those documents becomes important, someone is going to google for the namespace and get a pointer to the wrong thing. Worse still, your little vocabulary for CD catalogs might become a runaway success to the extent that aircraft manuals want to use it for their register of training videos for maintenance technicians, and then you get a conflict that could have been avoided if you'd chosen a name with more care.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164