[jdom-interest] Square brackets: internal subset or what ?

Bradley S. Huffman hip at cs.okstate.edu
Fri Apr 16 10:15:12 PDT 2004


"Italo Compostella" writes:

> The goal is to produce a xml file from a sql query. The file
> looks fine except the last line:
> 
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <result>
>   <entry>
>     <client_no>9</client_no>
>     <first_name>Aliane</first_name>
>     <last_name>Frei</last_name>
>     <street>Teststr</street>
>     <house_no>3</house_no>
>   </entry>
>   <entry>
>     <client_no>10</client_no>
>     <first_name>Peter</first_name>
>     <last_name>Busy</last_name>
>     <street>Teststr</street>
>     <house_no>3</house_no>
>   </entry>
> </result>
> [Document:  No DOCTYPE declaration, Root is [Element: <result/>]]
> 
> I produce this with the following code snippet:
> 
> ************************
>  else {
>               Element rootElement = new Element("client");
>               xmlDoc = new Document(rootElement);
> 
>               try {
>                   ResultSetBuilder builder = new
> ResultSetBuilder(rs);
>                   xmlDoc = builder.build();
>               }
>               catch (JDOMException e) {e.printStackTrace();}
>              
>               try {
>                   write(xmlDoc);
>               }
>               catch (IOException e) {e.printStackTrace();}
>             }
> 
>    private void write(Document doc) throws IOException {
>         File               outFle   = new
> File("..\\webapps\\myRep\\src", "shouse.xml"); 
>         PrintWriter        output   = new PrintWriter(
>                                       new BufferedWriter(
>                                       new FileWriter(outFle))); 
>         
>         XMLOutputter out = new
> XMLOutputter(Format.getPrettyFormat());    
>         out.setEncoding( "ISO-8859-1" );
>         out.output(doc, output);         
>          
>         output.print(doc);
>         output.close();
>     }
> *****************************
> 
> How can I get rid of that line in the square brackets?

Get rid of the output.print(doc) before the output.close() :-)

Brad



More information about the jdom-interest mailing list