nicolaken 2003/01/14 09:22:30 Modified: . changes.xml src/blocks/batik/java/org/apache/cocoon/serialization SVGSerializer.java Log: <action dev="NKB" type="fix" fixes-bug="13247" due-to="[EMAIL PROTECTED]" due-to-email="[EMAIL PROTECTED]"> Fix PNG output of SVGSerializer because The PNGTranscoder of Batik closes the stream. </action> Revision Changes Path 1.338 +6 -1 xml-cocoon2/changes.xml Index: changes.xml =================================================================== RCS file: /home/cvs/xml-cocoon2/changes.xml,v retrieving revision 1.337 retrieving revision 1.338 diff -u -r1.337 -r1.338 --- changes.xml 14 Jan 2003 10:36:48 -0000 1.337 +++ changes.xml 14 Jan 2003 17:22:29 -0000 1.338 @@ -40,6 +40,11 @@ </devs> <release version="@version@" date="@date@"> + <action dev="NKB" type="fix" fixes-bug="13247" + due-to="[EMAIL PROTECTED]" due-to-email="[EMAIL PROTECTED]"> + Fix PNG output of SVGSerializer because The PNGTranscoder of Batik + closes the stream. + </action> <action dev="CZ" type="update"> Renaming components section for pipeline implementations to "pipes" and "pipe". </action> 1.3 +11 -5 xml-cocoon2/src/blocks/batik/java/org/apache/cocoon/serialization/SVGSerializer.java Index: SVGSerializer.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/blocks/batik/java/org/apache/cocoon/serialization/SVGSerializer.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- SVGSerializer.java 8 Jan 2003 16:27:13 -0000 1.2 +++ SVGSerializer.java 14 Jan 2003 17:22:30 -0000 1.3 @@ -82,7 +82,7 @@ import org.xml.sax.ext.LexicalHandler; import java.awt.Color; -import java.io.BufferedOutputStream; +import java.io.ByteArrayOutputStream; import java.io.OutputStream; /** @@ -128,7 +128,7 @@ * Set the <code>OutputStream</code> where the XML should be serialized. */ public void setOutputStream(OutputStream out) { - this.output = new BufferedOutputStream(out); + this.output = out; } /** @@ -265,9 +265,15 @@ public void notify(Document doc) throws SAXException { try { TranscoderInput transInput = new TranscoderInput(doc); - TranscoderOutput transOutput = new TranscoderOutput(this.output); + + // Batik's PNGTranscoder closes the output stream. + // Therefore we cannot pass it this.output directly. + // Otherwise we get an exception when Cocoon.process + // tries to flush/close the stream again. + ByteArrayOutputStream baos = new ByteArrayOutputStream(8192); + TranscoderOutput transOutput = new TranscoderOutput(baos); transcoder.transcode(transInput, transOutput); - //this.output.flush(); + baos.writeTo(this.output); } catch (Exception ex) { log.error("SVGSerializer: Exception writing image", ex); throw new SAXException("Exception writing image ", ex);
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]