[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Classpathx-xml] GNUJAXP.JAR Bug in gnu.xml.pipeline.TextConsumer constr

From: Arnd Beißner
Subject: [Classpathx-xml] GNUJAXP.JAR Bug in gnu.xml.pipeline.TextConsumer constructor
Date: Tue, 2 Apr 2002 11:00:01 +0100

Hi there,

I found the following bug in JAXP 1.0beta1 (distribution download):

when the TextConsumer class is used to emit plain XML (not specially handled XHTML),
the XML declaration is missing in the output TextConsumer produces.

Here's the reason:

>    public TextConsumer (Writer w, boolean isXhtml)
>    throws IOException
>    {
>        super (w, isXhtml ? "US-ASCII" : null);
>        setXhtml (isXhtml);
>    }

The XMLWriter class does not emit the XML declaration if no encoding
is given. TextConsumer passes null for the encoding parameter is isXhtml
is false.

Here's my ad-hoc fix:

>    public TextConsumer (Writer w, boolean isXhtml)
>    throws IOException
>    {
>        super (w, isXhtml ? "US-ASCII" : "UTF8");
>        setXhtml (isXhtml);
>    }

My opinion:
I think both XMLWriter and TextConsumer are at fault here. I understand
the reason for omitting the XML delaration when (X)HTML output is desired.
However, the encoding parameter of XMLWriter's constructor should not be
hijacked for that purpose. I'd say there needs to be a separate property for this
AND TextConsumer needs my fix AND TextConsumer should have a
constructor of the form  public TextConsumer (Writer w, String encoding, boolean isXhtml)

The TextConsumer constructor with a Writer argument is sometimes preferable over the
OutputStream variant - for example when you want output to a String - there's a StringWriter
standard class but not a StringBufferOutputStream.

Arnd Beissner
Cappelino Informationstechnologie GmbH
Arnd Beißner
Bahnhofstr. 3, 71063 Sindelfingen, Germany
Email: address@hidden
Phone: +49-7031-463458
Mobile: +49-173-3016917

reply via email to

[Prev in Thread] Current Thread [Next in Thread]