[jdom-interest] XMLOutputter.output() and xml:lang attribute results in lang outp ut

Butt, Vaughn A. vaughn.butt at nz.unisys.com
Sun Dec 8 20:45:24 PST 2002

I am trying to get an org.jdom.Element as a string by using
org.jdom.XMLoutput(Element element,Writer writer) where the writer is a

My problem is that the source elements with an attribute xml:lang="en-US" in
it are being streamed to my StringWriter as an element with plain

I checked the FAQ (http://jdom.org/docs/faq.html) and found that "The
xml:lang and xml:space attributes are special cases that are allowed..." but
it does not say how JDOM deals with them.

I want to the "xml:" included in my output.

Can I do this (eg by set some attribute on XMLOutputter)?

If I can how is it done?

If I can't then please let me know.

TIA (hopefully)
Vaughn Butt
Software Developer

PS. Here is the (rather ugly and slightly incomplete) code that I want to be
able to get this output from.

public class Migration {
    public static void main(String[] args) {
        org.w3c.dom.Document domDocument = methodThatReturnsADOMDocument();

        org.jdom.Document doc = new DOMBuilder().build(domDocument);


    private static String element2String(Element element) {
        String retVal = null;
        XMLOutputter outputter = new XMLOutputter("    ",true);
        try {
            StringWriter sw = new StringWriter();
            retVal = sw.toString();
        catch (IOException e) {
        return retVal;

More information about the jdom-interest mailing list