Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Serialize selected elements to a Writer.

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: "David Bullock" <db AT dawnbreaks.net>
  • To: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Serialize selected elements to a Writer.
  • Date: Sat, 14 Oct 2006 02:10:52 +1000

On 10/14/06, John Cowan <cowan AT ccil.org> wrote:

Elliotte Harold scripsit:

> The problem is that a Writer doesn't give you enough information to tell
> which characters need to be escaped and which don't. JDOM floundered on
> this shoal too, though they went the other way; serializing to writers
> but potentially producing malformed output. I'm not sure there's a
> good option here. :-(

If the Writer is an instance of StringWriter or CharArrayWriter, you
can safely use the full Unicode repertoire. Otherwise, assume the ASCII
repertoire (even EBCDIC OutputStreamWriters implement that much).




OK, I see what TextWriter is doing. Well, given that the configurable state
of an nu.xom.TextWriter is simply a Writer and an encoding, what's to
prevent a constructor like:

Serializer(Writer out, String encoding)

... if I happen to lie about the encoding, then that's my own fault? In the
specific JSP use-case I'm discussing, I can reliably
pageContext.getResponse().getCharacterEncoding()
... so it's not an issue to actually supply the 'meta info' about the Writer
externally, if the Writer interface won't itself provide it.


Just a thought.

cheers,
David.




Archive powered by MHonArc 2.6.24.

Top of Page