[jdom-interest] XMLOutputter Question

tfaust at pagedigital.com tfaust at pagedigital.com
Tue Nov 18 15:23:56 PST 2003


Neil,

The processing instructions are always retained. I guess you must be doing 
something to suppress their output. Here is an example that outputs just 
fine, as shown below.


import java.io.StringReader;
import org.jdom.Document;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;

public class OutputTest {
 
    public void parse(String xml) throws Exception {
        StringReader r = new StringReader(xml);
        SAXBuilder b = new SAXBuilder();
        Document d = b.build(r);
        XMLOutputter o = new XMLOutputter("  ",true);
        o.output(d,System.out); 
    }

    public static void main(String[] args) {
        OutputTest ot = new OutputTest();
        try {
            ot.parse("<?xml version=\"1.0\" encoding=\"UTF-8\" 
?><Test><value>3</value></Test>");
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

}


The output looks like this:


<?xml version="1.0" encoding="UTF-8"?>
<Test>
  <value>3</value>
</Test>



Tom Faust
Product Architect
Page Digital, Inc.
http://www.synaro.com






"Hainer, Neil" <hainern at jivanet.net>
Sent by: jdom-interest-admin at jdom.org
11/18/2003 03:52 PM
 
        To:     <jdom-interest at jdom.org>
        cc: 
        Subject:        [jdom-interest] XMLOutputter Question


Hi,

I am reading in an XML document and writing it out using XMLOutputter(). 
The input document contains 

"<?xml version "1.0" encoding = "UTF-8"?>

as the first line.  The output file does not contain this line.  Can 
someone tell me why?  Is there a way to retain it?

TIA,

Neil

Neil Hainer
Booz | Allen | Hamilton
JIVA SI
8613 Lee Hwy
Fairfax, VA 22031
703-289-3881

_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20031118/34e57e68/attachment.htm


More information about the jdom-interest mailing list