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

Rasmus Pedersen RUP at sjp.dk
Sun Dec 8 23:52:53 PST 2002

I think I might have a related question, and I can't (sorry) answer the first one. 

Can the first line in the XML output 
"<?xml version="1.0" encoding="UTF-8"?>"
be avoided? I am using java.lang.String outputString(Document doc) of the XMLOutputter class.
Thanks in advance, Rasmus

Med venlig hilsen
Rasmus Pedersen
Ph.d./Erhvervsforsker stud.
Stig Jørgensen & Partners
Lyngsø Allé 3
2970   Hørsholm
Telefon: 45 74 45 00
Direkte: 45 74 47 26
Mobil:    21 46 49 58  
rasmus.pedersen at sjp.dk

Kind regards
Rasmus Pedersen
Indust. Ph.d. stud.
Stig Jørgensen & Partners
Lyngsoe Allé 3
DK-2970   Hoersholm
Phone:  +45 45 74 47 00 
Direct:  +45 45 74 47 26
Mobile: +45 21 46 49 58
rasmus.pedersen at sjp.dk 

>>> "Butt, Vaughn A." <vaughn.butt at nz.unisys.com> 12/09/02 05:45am >>>
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;

To control your jdom-interest membership:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20021209/a027c6da/TEXT.htm

More information about the jdom-interest mailing list