[jdom-interest] problem xmlns namespace

Philipp Gröschler philipp.groeschler at kamp-dsl.de
Mon Nov 17 06:17:01 PST 2003


Not 100% solution, but try this:

<code>

Element rootElement = new Element("document");
Namespace ns = Namespace.getNamespace ("xf",
"http://apache.org/cocoon/xmlform/1.0");
Attribute root_ns = new Attribute ("narf", "value", ns);
rootElement.setAttribute (root_ns);

</code>

That would create an additional argument "narf" (or whatever name you
choose) which hangs in there and does just nothing. The result would be

<document xmlns:xf="http://apache.org/cocoon/xmlform/1.0"
xf:narf="value" />

Maybe you want a xf-argument in the <document> start tag, then you can
go this way. This would generate nearly the xml that you want, but I
don't think this document is well formed. Normally, the namespace
declaration should be in the first element that uses the matching
prefix. (Correct me if I'm wrong)




More information about the jdom-interest mailing list