[jdom-interest] Namespace issues, et al.

bob mcwhirter bob at werken.com
Mon Feb 24 07:49:32 PST 2003

> The 'bug' is that you can not inherit namespace from the parent -- even 
> though the spec says you can
> and the XMLOutputter will output a document that does, and SAXBuilder reads 
> a document that does....
> anotherwords -- everything works on the assumption that you can inherit 
> whatever namespace you are in
> based on the scope, as per the spec -- EXCEPT when creating them from 
> scratch. When creating them from
> scratch, I can not create a <url href="http://someurl"/> element and tell 
> it to stay in the same namespace
> defined in the scope of the parent element....  But this is only a 'bug' 
> when creating documents. It can
> not be a 'feature' if it fails to work the same creating documents as it 
> does outputting documents and
> reading documents.  Inconsistency is a 'bug'.

I think this is also an issue of the definition of 'inheritence'.

You certainly can inherit namespaces to sub-elements of the element upon
which it is defined.  But, not from the JDOM side.  From JDOM, you're
-attaching- complete Element nodes to an existing tree, not pasting in
the octets from a serialized XML document.

The declarations of xmlns are inherited and available to children,
Element nodes, but to be InfoSet compliant, each Element contains its
own local-name and namespace information item, and is not dependent
upon context.

In no way do children elements by default 'live' in the namespace of
the parent.  No spec says that.  It says that namespace decls and prefix
are available ("in scope") for all children, if they choose to use it.

Making a special case out of having an otherwise unspecified child tagged
with the namespace of the parent is simply wrong.  No specification
would support that argument.

Making a special case out of having an otherwise unspecified child tagged
with the default namespace is also simply wrong.  This usage would be
affected by whether you're using an explicit ns-prefix or a default ns.

So, while you're reading the XML spec and thinking in terms of serialized
octets, I think it'd be wise to read the InfoSet specification also.

I really hate playing the "trust us" card, but many folks have used JDOM
(and dom4j and all of the other models that work the same way) for years
and satisfied with the semantics of how elements are

As a (former? jason, what's my status, if it even matters?) member of the
JDOM expert group, I'd strongly vote against your proposed modifications
to the API as being dangerous.

Anyhow, I'm tiring of this argument.


More information about the jdom-interest mailing list