Hi Toby
There is an issue if you use OutputStream rather than Writer when using
XMLWriter, you should explicitly always call a flush() afterwards to ensure
that all the output goes to the OutputStream.
The code used to always call a flush internally inside the write(Document)
method but I decided to remove it, as when using dom4j in JSP / Servlet
environments this can lead to inefficiency, so I'd prefer to leave calls to
flush() or close() up to the developer.
So the following is recommended...
OutputFormat format = org.dom4j.io.OutputFormat.createPrettyPrint();
XMLWriter writer = new XMLWriter( out, format );
writer.write( someDocument );
writer.flush();
if you are writing the entire document to (say) a file, then close() is a
good alternative to calling flush() as you should close the underlying
file's output stream.
I'm looking forward to your docmanager work ;-)
Would you like to add it to CVS then we can put it on the main website too?
James
----- Original Message -----
From: "Tobias Rademacher" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, June 13, 2001 10:17 AM
Subject: [dom4j-user] Problems with XMLWriter in Nightly build when close()
is missing
> Hi,
>
> I'm using the latest build of dom4j in order to get the clone/copy Patch.
No
> I explored a possible bug in XMLWriter. I transformed a xml source with
> TraX-Dom4j-Saxon and I want to serz�alize the result to disk using
> #write(Document doc) method. The Writer class produces a currupted xml
file which is half
> complete only. Seems to me that the writer is broken interal but there's
no
> exception thrown.
>
> Code-Snipplet:
>
> XMLWriter writer = new
> XMLWriter(org.dom4j.io.OutputFormat.createPrettyPrint());
> writer.setWriter(new FileWriter(this.applicationPath +
> "/DOM4JResult.xml"));
> writer.write((org.dom4j.Document) testOM);
>
>
> I added writer.close(); add to my code and the result is now correctly.
> Interesting is:
> the code without #close() works fine in dom4j 0.4 so we have to point it
out
> this change in release notes or fix it if it is wrong.
> If this behavior is correct i will add it to my cookbook that I'm
currently
> writing. I will also submit a pre-alpha release at this evening at
> sourceforge docmanager.
>
> Kind regards.
>
> --
> GMX - Die Kommunikationsplattform im Internet.
> http://www.gmx.net
>
> --
> GMX Tipp:
>
> Machen Sie Ihr Hobby zu Geld bei unserem Partner 1&1!
> http://profiseller.de/info/index.php3?ac=OM.PS.PS003K00596T0409a
>
>
> _______________________________________________
> dom4j-user mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/dom4j-user
>
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dom4j-user