[jdom-interest] Default Namespace vs No-Namespace.
John Jefferson
surfer97301 at yahoo.com
Thu Jul 3 10:16:44 PDT 2003
Hi,
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.
Why is jdom's behavior set such that when I have a
document and I set the default namespace at the root
the child nodes of the root do not inherit the
namespace but instead are set to the special
no-namespace namespace.
This is problematic for me. What I am doing is
receiving an xml file from an untrusted source. What
I then what to ensure is that this xml validate
against my particular schema/dtd.
In order to do this, I build the document with SAX.
Get the root element and set the root elements
namespaces, etc such that this document is using my
schemas/dtds. Now I write this document back out and
read it in again in order to validate it but since the
XmlOutputter gives the root children the no-namespace,
the document fails validation.
I did read over your faq. It would seem to me that
having to iterate though every node in the document
and setting that node to the default namespace fails
many of the JDOM philisophies. It is not
straigtforward, in that if I were modifying the text
document and I changed the default namespace all child
elements would inherit this change. It is not
efficient, in that to get what I want I'd have to
change every element in the tree. As far as being
true to the xml spec, I can't speak to that as much
but it seems to me that the default namespace is a
special namespace and should be treated as such, I
should be able to set the default namespace and have
it propagate to all nodes that do not have a
namespace.
Is not having a namespace synomynous with having the
no-namespace?
Thanks,
JJ
--- Jason Hunter <jhunter at servlets.com> wrote:
> Once you understand the default namespace is just
> "the namespace with an
> empty space prefix" things will be more clear to
> you. The name "default
> namespace" is actually unfortunate in my opinion
> because it implies it's
> there in the absence of any other namespace, but in
> fact there's always
> a special "no namespace" in the absence of any other
> namespace.
>
> The JDOM FAQ has more on this topic.
>
> -jh-
__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com
More information about the jdom-interest
mailing list