[jdom-interest] document encoding

Ken Rune Helland kenh at csc.no
Thu Jun 28 01:59:24 PDT 2001


At 01:57 PM 6/27/2001 -0700, Jason Hunter wrote:
> > Is it possible for SAXBuilder to store the encoding type inside the built
> > Document, so that XMLOutputter will use the same encoding when outputting?
> >  - or -
> > Is there any other way to "remember" the input encoding and use it for
> > output?
>
>SAX doesn't report the encoding, unfortunately.
>
>-jh-


The encoding, if it is declared, is in the very beginning of
the xml file, it shoud not be much work to pick it out.

Maybe a FilterStream/FilterReader subclass that locks for
the <?xml ... ?> line and remebers the encoding declared.

This way people that worry about the encoding can wrap their
incomming xml in this "EncodingFinderStream" before
handing it to the SAXBuilder.

Woud cost a little bit of cpu performance to do this
since all reads will have an extra fuction call.

I woud asume the stream woud be used for a single
XML-file only since SAXBuilder looks for the EOF.


If I have time I'll write one and contrib it, unless someone
commes up with a reason it is a very bad idea.


KenR




More information about the jdom-interest mailing list