[jdom-interest] Default Namespace vs No-Namespace.

Jason Hunter jhunter at servlets.com
Thu Jul 3 13:55:10 PDT 2003


John Jefferson wrote:
>>>The default namespace is a feature of xml which
>>
>>allows
>>
>>>you to declare one namespace at the top and for any
>>>element in the document which is not given a
>>
>>namespace
>>
>>>that element will inherit the default namespace.
>>
>>No, this statement is not true. Namespaces are quite
>>a bit more 
>>complicated than that. When  designing an API, it's
>>important to be 
>>really precise and clear about these things.
> 
> Maybe you can enlighten me on this point.  Or point me
> to something easier to digest than the xml namespace
> spec.  

As I wrote previously, the name "default namespace" was poorly chosen 
because it implies it acts as a default in the absence of something.  It 
also implies there's just one.  Simply think of a default namespace as 
any namespace that happens to have an empty string prefix.

Considering that you have have a large number of "default namespaces" in 
a single document (as many as one per element) and that elements are 
built without knowing where they're going to go, we really wouldn't even 
know which of the many default namespaces to choose for any new element. 
  It'd have to be decided when it was added to a parent.  But an element 
should have a namespace URI independent of its current location in a 
tree so that if I asked the element can know if it's an xhtml:table or a 
furniture:table.  It shouldn't have to say, "Wait til I'm added 
somewhere and I'll let you know.  And the answer may change when I move."

I'm a huge -1 against removing the constructor that takes only a name. 
Many documents out there don't have namespaces and people who don't use 
namespaces shouldn't have to use namespaces.  :-)

We've talked about this all before and the design is correct.  Nothing 
to see here.  Move along.  :-)

-jh-




More information about the jdom-interest mailing list