[XOM-interest] Unusual output when using default namespaces
tom_hurley at anabus.com
Tue Dec 16 17:11:47 EST 2003
That makes sense. Thanks for the help.
From: jcowan at reutershealth.com [mailto:jcowan at reutershealth.com]
Sent: Tuesday, December 16, 2003 4:41 PM
To: Tom Hurley
Cc: xom-interest at lists.ibiblio.org
Subject: Re: [XOM-interest] Unusual output when using default namespaces
Tom Hurley scripsit:
> I'm getting some unusual output when I specify a default namespace for an
> element. The subsequent element node(s) also include a xmlns="" attribute
> even though I haven't specified one. For example:
This is what you should see. In your code below,
> Builder builder = new Builder();
> Element docRoot = new Element("anabus",
> Document docABD = new Document(docRoot);
> Element project = new Element("project");
the line above creates an element named "project" in no namespace. The
decides to use the root element's namespace as the default namespace, which
is usually the Right Thing, and so the project element has to have the
namespace explicitly reset. If you want all the elements to be in the root
namespace, you have to create each of them in that namespace.
> (2) The xmlns="" attribute is added to every child element of
> the document root element but not to any of their children.
Within each child element, the default namespace is "no namespace", so there
is no need to reset it in the grandchildren.
> Am I doing something wrong?
That depends on what you want.
All Norstrilians knew what laughter was: John Cowan
it was "pleasurable corrigible malfunction". http://www.reutershealth.com
--Cordwainer Smith, _Norstrilia_ jcowan at reutershealth.com
More information about the XOM-interest