[jdom-interest] Weird namespace attribute when using JAXP transformer

Oliver Koell listen at quimby.de
Fri Oct 22 09:27:17 PDT 2004


Hi all,

I want to serialize my JDOM documents using JDOMSource and a JAXP 
identity transformer (the variant without stylesheet) because i need 
HTML output (method = "html). Here is the output for a very simple 
document:

   <?xml version="1.0" encoding="UTF-8"?>
   <html xmlns:=""></html>

I'm wondering, where the xmlns:="" attribute on the root element comes 
from - i do not get this with an equivalent W3C document and DOMSource.

My code looks like this:

   Document doc = new Document(new Element("html"));

   TransformerFactory fact = TransformerFactory.newInstance();
   Transformer tf = fact.newTransformer();
   tf.setOutputProperty(OutputKeys.METHOD, "html");

   Source source = new JDOMSource(doc);
   Result result = new StreamResult(System.out);
   tf.transform(source, result);

(note, that the "html" output method is not actually relevant. I get 
the same result for "xml" output).

Does anybody have some insight where the namespace attribute is coming 
from and how to get rid of it? This would be very much appreciated.

Another question: are there any alternatives for producing HTML from 
JDOM documents?

Regards, Oliver



More information about the jdom-interest mailing list