Martin Probst's weblog

Namespaces

Monday, March 14, 2005, 13:08 — 1 comment Edit

Every now and then someone thinks about namespaces and nearly everyone seems to be at least slightly confused afterwards. David Magginson tries to clarify on that, although he admits the decision the Namespace group has taken is not really perfect.

Now what really bugs me is that according to his post (and Dare Obasanjo has written about that before too) there are three cases for the namespace of an attribute:

The annyoing thing about that is in my opinion the “locally scoped” case. I might miss something, but I don’t see any other XML standard that really requires or uses that “locally scoped” feature. At least XPath, XQuery etc. don’t use it, and XML Schema as far as I know doesn’t too, does it?

The namespace should have been either inherited from the element the attribute is in or (in my opinion clearer) been the default namespace set with <myelem xmlns=“foo”/>. There should really not be any difference between elements and attributes regarding XML namespaces as both use the same syntax (QNames). Using the inherit-mechanism not only for attributes but for elements also might bring strange effects when including XML snippets within other documents.

Another solution would be to forbid elements without explicit namespace prefixes altogether. This would bring some annyoance to users who do not use XML namespaces or just use one within one document, but it would also be absolutely clear. I would prefer to have a clear syntax instead of surprising effects when using namespaces …


Just to add some confusion. Case 1 is not allowed according to Namespace Spec 1.0. It is allowed according to Namespace Spec 1.1.