Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Unusual output when using default namespaces

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: jcowan AT reutershealth.com
  • To: Tom Hurley <tom_hurley AT anabus.com>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Unusual output when using default namespaces
  • Date: Tue, 16 Dec 2003 16:41:06 -0500

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",
> "http://www.anabus.com/tobago_cays";);
>
> Document docABD = new Document(docRoot);
>
> Element project = new Element("project");

the line above creates an element named "project" in no namespace. The
serializer
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 default
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




Archive powered by MHonArc 2.6.24.

Top of Page