[jdom-interest] Request for help using JDOM Beta 6 to create namespace declaratio n

Jason Hunter jhunter at acm.org
Fri May 11 11:44:40 PDT 2001


> The output I have been able to achieve using  the ctor public
> Element(java.lang.String name, Namespace namespace) is:
> 
> <!DOCTYPE mdc SYSTEM "MeasDataCollection.dtd">
> <HTML:mdc xmlns:HTML="http://www.w3.org/TR/REC-xml">
> </HTML:mdc>

You want

Namespace html = Namespace.getNamespace("HTML", "http://...");
Element e = new Element("mdc");
e.addNamespaceDeclaration(html);

By passing the html Namespace to the mdc element in its constructor you
were placing the elt in that namespace, which is not what you wanted. 
The addND() call adds a declaration without putting the elt in the
namespace.

-jh-



More information about the jdom-interest mailing list