fsociety
fsociety

Reputation: 1027

Who checks that XML namespaces are unique?

I understand that XML namespaces must be unique to avoid name conflicts/collisions for elements. But what I don't understand is where exactly is this conflict being checked? Who will verify/validate the uniqueness of namespaces?

For example consider the below example taken from one of the threads on stack overflow:

<config xmlns:rnc="http://www.abcde.com/r1" xmlns:bsc="http//www.pqrs.com/r2">
  <rnc:node>
      <rnc:rncId>5</rnc:rncId>
  </rnc:node>

  <bsc:node>
      <bsc:cId>5</bsc:cId>
  </bsc:node>
</config>

Now www.abcde.com and www.pqrs.com are made up urls which do not exist? So who validates/verifies the authenticity? I can give some random keyword and it will still work? So what's the whole point? Is there some central repository that is looked into? Please clarify in layman terms.

Upvotes: 2

Views: 136

Answers (1)

kjhughes
kjhughes

Reputation: 111686

An XML namespace name URI need not be retrievable, and there is no central authority to govern the use or creation of namespaces. There is an implied norm that only the holder of a domain may create namespaces based on that domain.


Update to address OP's questions in comments:

But i intend to know that if 2 people are unwillingly using the same namespace, there is no way for them to know?

Many people can use many namespaces without coordination; that is the point to namespaces.

Only the holder of the domain on which a namespace is based should ever define a namespace using that domain.

Also, i use the same namespace for 2 different elements locally, then will the conflict arise locally?

There is no intrinsic problem with having different elements with the same namespace; it is quite common, in fact.

Who checked my xml file locally? Is there some validation step?

XML files can be validated against an XSD, which can specify namespaces in the definition the vocabulary and grammar rules that define the validity of the XML file.

Upvotes: 2

Related Questions