[jdom-interest] Strange namespace problem

Marcel Stör marcel at frightanic.com
Mon Nov 24 14:56:25 PST 2003

Per Norrman <mailto:pernorrman at telia.com> wrote:
> Hi,
> I think what Eliotte meant was that in your particular
> case, you shouldn't use setNamespace and addNamespaceDeclaration.
> There are legitimate uses for both methods. If you call the Element
> constructor or the setAttribute method with the
> namespace argument, the namespace declaration comes for free.

Ok, got that.
> However, your problem was the subsequent customer element, right? The
> question is, what namespace does the customer element belong to?
> If it belongs to no namespace, everything is OK, the XML produced is
> valid. <customer xmlns=""> is perfectly valid, as per section 5.2 of
> the namespace spec: http://www.w3.org/TR/REC-xml-names/#defaulting.

Well, it belongs to the default namespace declared in the root element
(http://www.it-p.ch/namespace). When the customer element was produced
the was no namespace declaration through the constructor nor through the
setNamespace method.
Anyway, XMLSpy tells me that <customer xmlns=""> wasn't valid XML at

> If it should belong to another namespace, you must explicitly state
> that,
> using either the constructor or the setNamespace method (and for the
> children
> too, if applicable).

Thanks for your explanations.


More information about the jdom-interest mailing list