[jdom-interest] XMLOutputter & StringWriter

Gabor Greif gabor at no.netopia.com
Mon Jul 3 10:34:34 PDT 2000


On Mon, Jul 3, 2000 19:07 Uhr, Jason Hunter <mailto:jhunter at collab.net>
wrote:
>> Are you sure you checked in?
>
>Ah, you're right.  Sorry about the miscommunication.  Elliotte changed
>the class to use a Writer internally but the public API lacks a method
>that accepts a Writer.  So what do people think of adding output()
>methods that accept Writers?  I think it'd be a fine addition, but with
>one twist.  I propose we don't provide
>
>output(Document, Writer)
>
>and only provide
>
>output(Document, Writer, String encodingOfWriter)
>
>This is because the top method requires the Writer to be a Writer for
>the same encoding that we have as default (UTF-8), or the encoding that
>was passed in to the constructor (could be anything).  That seems
>awfully risky.  Forcing you to specify will keep people from calling
>this in a servlet:
>
>outputter.output(doc, res.getWriter())
>
>It seems perfectly reasonable, but since we default to UTF-8 and
>servlets default to Latin-1, you'll have serious problems.  Opinions?
>
>-jh-

In my understanding all Writers are (unicode) character streams. This way
you get rid of the encoding problem, that only arises when going to _byte_
streams and vica versa. So you only need the encoding parameter for the
character <--> byte stream transition.
Since the proposed method does not involve byte streams, and all info in a
Document is represented(able) as characters, encoding is not necessary.

My knowledge comes from

http://java.sun.com/products/jdk/1.2/docs/guide/io/io.html

Regards,

	Gabor






More information about the jdom-interest mailing list