[jdom-interest] XMLOutputter naming questions

Elliotte Rusty Harold elharo at metalab.unc.edu
Mon Oct 2 04:42:45 PDT 2000

At 11:42 AM -0700 10/1/00, Alex Chaffee wrote:
>It gets complicated when I start thinking about encodings.  What if
>the XMLOutputter tries to use a fancy character encoding and prints
>funny bytes to a byte array, then when you call toString() won't it
>interpret them as ASCII/Unicode and screw up?  Makes my head hurt.

Yes, it does, doesn't it? The lack of a generic getEncoding() method 
in Writer really hurts. This is precisely what originally led me to 
propose separating serialization into XMLSerializer and outputting 
into XMLOutputter. You can't guaranteededly do the right thing if you 
don't know what encoding you're dealing with.

Thery're a number of partial solutions but none of them are pretty. 
You can work strictly with output streams instead of writers. You can 
ask the client to pass in the encoding name as an extra argument. You 
can require OutputStreamWriter and StringWriter specifically in your 
method signatures rather than Writer; but none of these are good 

| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
|                  The XML Bible (IDG Books, 1999)                   |
|              http://metalab.unc.edu/xml/books/bible/               |
|   http://www.amazon.com/exec/obidos/ISBN=0764532367/cafeaulaitA/   |
|  Read Cafe au Lait for Java News:  http://metalab.unc.edu/javafaq/ |
|  Read Cafe con Leche for XML News: http://metalab.unc.edu/xml/     |

More information about the jdom-interest mailing list