Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Serialization API

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Rusty Harold <elharo AT ibiblio.org>
  • To: XOM API for Processing XML with Java <xom-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] Serialization API
  • Date: Thu, 30 Sep 2010 07:07:58 -0400

On Wed, Sep 29, 2010 at 2:15 PM, Dmitry Katsubo <dma_k AT mail.ru> wrote:
> Dear Elliotte,

>> Your code uses a StringWriter. Problems arise with something like this:
>>
>> Writer out = new OutputStreamWriter(new ByteArrayOutputStream(),
>> "ISO-8859-1");
>
> This case worked fine for me. If you specify the encoding for output
> stream, it works OK. Diff is attached.

The problem comes when you attempt to write a character such as the
Greek letter alpha onto this writer. That can't be represented in
8859-1 but XOM has no way of knowing that.

I suppose I could just escape all non-ASCII characters when writing to
a Writer, but that's really ugly and even that doesn't work if the tag
names contain non-ASCII.


> I think, the same characters should be escaped as for OutputStream (no
> difference). Unescaped characters should be left in UTF8.

You can't leave characters in UTF-8 if the writer doesn't write UTF-8.
With an output stream, XOM knows which characters it must escape and
which ones it doesn't have to escape. With a writer XOM doesn't know
that.

--
Elliotte Rusty Harold
elharo AT ibiblio.org




Archive powered by MHonArc 2.6.24.

Top of Page