Skip to Content.
Sympa Menu

xom-interest - [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: "Tom Hurley" <tom_hurley AT anabus.com>
  • To: <xom-interest AT lists.ibiblio.org>
  • Subject: [XOM-interest] Unusual output when using default namespaces
  • Date: Tue, 16 Dec 2003 16:50:28 -0500

Hi,



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:



<?xml version="1.0" encoding="UFT-8" ?>

<anabus xmlns="http://www.anabus.com/tobago_cays/";>

<project id="1" xmlns="" />

</anabus>



is produced by the following code:



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");

Attribute projectAttr = new Attribute("id", "1");

project.addAttribute(projectAttr);

docRoot.appendChild(project);



FileOutputStream output = new FileOutputStream(xmlFileToCreate);

Serializer serializer = new Serializer(output, "UTF-8");

serializer.setIndent(2);

serializer.write(docABD);



NOTES:

(1) It does not seem to matter whether I use 'appendChild' or 'insertChild'
as the behaviour is the same.

(2) The xmlns="" attribute is added to every child element of
the document root element but not to any of their children.



Am I doing something wrong?



Thanks again in advance.



Tom.





Archive powered by MHonArc 2.6.24.

Top of Page