Return-Path: Delivered-To: apmail-cocoon-docs-archive@www.apache.org Received: (qmail 25395 invoked from network); 10 May 2007 10:34:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 May 2007 10:34:58 -0000 Received: (qmail 48730 invoked by uid 500); 10 May 2007 10:35:04 -0000 Delivered-To: apmail-cocoon-docs-archive@cocoon.apache.org Received: (qmail 48712 invoked by uid 500); 10 May 2007 10:35:03 -0000 Mailing-List: contact docs-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: docs@cocoon.apache.org List-Id: Delivered-To: mailing list docs@cocoon.apache.org Received: (qmail 48697 invoked by uid 99); 10 May 2007 10:35:03 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 May 2007 03:35:03 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.130] (HELO eos.apache.org) (140.211.11.130) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 May 2007 03:34:56 -0700 Received: from eos.apache.org (localhost [127.0.0.1]) by eos.apache.org (Postfix) with ESMTP id 8789659A07 for ; Thu, 10 May 2007 10:34:36 +0000 (GMT) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Apache Wiki To: docs@cocoon.apache.org Date: Thu, 10 May 2007 10:34:36 -0000 Message-ID: <20070510103436.18834.5648@eos.apache.org> Subject: [Cocoon Wiki] Update of "UseCocoonXMLSerializerCode" by AlexanderKlimetschek X-Virus-Checked: Checked by ClamAV on apache.org Dear Wiki user, You have subscribed to a wiki page or wiki category on "Cocoon Wiki" for change notification. The following page has been changed by AlexanderKlimetschek: http://wiki.apache.org/cocoon/UseCocoonXMLSerializerCode New page: #FORMAT Java public static InputStream getInputStream(...my params...) throws IOException, SourceNotFoundException { Serializer serializer = createSerializer(); ByteArrayOutputStream outputStream = null; try { outputStream = new ByteArrayOutputStream(); serializer.setOutputStream(outputStream); // fill the serializer with SAX Events (it's a ContentHandler) MyBrilliantClass.toSAX(serializer, ...my params...); return new ByteArrayInputStream(outputStream.toByteArray()); } catch (SAXException e) { throw new CascadingIOException(e); } finally { if (null != outputStream) outputStream.close(); } } private static Serializer createSerializer() { // we use Cocoons XMLSerializer here which is configurable in terms // of the Transformer Implementation to use (some are buggy, so we // want to ensure which one is used) DefaultConfiguration transformerConfig = new DefaultConfiguration("transformer-factory", null); transformerConfig.setValue( "org.apache.xalan.xsltc.trax.TransformerFactoryImpl"); DefaultConfiguration serializerConfig = new DefaultConfiguration("serializer", null); serializerConfig.setAttribute("class", "org.apache.cocoon.serialization.XMLSerializer"); serializerConfig.addChild(transformerConfig); XMLSerializer serializer = new XMLSerializer(); serializer.enableLogging(new NullLogger()); try { serializer.configure(serializerConfig); } catch (ConfigurationException e) { throw new InitializationException( "could not confiure XMLSerializer", e); } return serializer; }