Return-Path: Mailing-List: contact cocoon-cvs-help@xml.apache.org; run by ezmlm Delivered-To: mailing list cocoon-cvs@xml.apache.org Received: (qmail 10165 invoked by uid 1203); 20 Dec 2000 23:12:47 -0000 Date: 20 Dec 2000 23:12:47 -0000 Message-ID: <20001220231247.10163.qmail@locus.apache.org> From: dims@locus.apache.org To: xml-cocoon-cvs@apache.org Subject: cvs commit: xml-cocoon/src/org/apache/cocoon/generation HTMLGenerator.java dims 00/12/20 15:12:46 Modified: src/org/apache/cocoon/generation Tag: xml-cocoon2 HTMLGenerator.java Log: Cleaning up JTidy usage. Revision Changes Path No revision No revision 1.1.2.5 +8 -19 xml-cocoon/src/org/apache/cocoon/generation/Attic/HTMLGenerator.java Index: HTMLGenerator.java =================================================================== RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/generation/Attic/HTMLGenerator.java,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -r1.1.2.4 -r1.1.2.5 --- HTMLGenerator.java 2000/12/08 20:39:36 1.1.2.4 +++ HTMLGenerator.java 2000/12/20 23:12:46 1.1.2.5 @@ -11,6 +11,7 @@ import org.apache.cocoon.components.parser.Parser; import org.apache.cocoon.ProcessingException; import org.apache.cocoon.Roles; +import org.apache.cocoon.xml.dom.DOMStreamer; import org.xml.sax.SAXException; import org.xml.sax.InputSource; @@ -26,7 +27,7 @@ /** * @author Davanum Srinivas - * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/12/08 20:39:36 $ + * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/12/20 23:12:46 $ */ public class HTMLGenerator extends ComposerGenerator implements Poolable { /** @@ -36,28 +37,16 @@ throws IOException, SAXException, ProcessingException { try { - URL url = new URL(this.source); - ByteArrayOutputStream ostream = new ByteArrayOutputStream(); - - // Setup an instance of Tidy. + // Setup an instance of Tidy. Tidy tidy = new Tidy(); tidy.setXmlOut(true); tidy.setXHTML(true); - // FIXME (DIMS): Using DOMStreamer will eliminate the need for an - // intermediate ByteArrayOutput Stream. But the document created - // by JTidy has problems. So for now we use the ByteArrayOutputStream. - tidy.parseDOM(new BufferedInputStream(url.openStream()), - new BufferedOutputStream(ostream)); - - log.debug("Looking up " + Roles.PARSER); - // Pipe the results into the parser - Parser parser=(Parser) this.manager.lookup(Roles.PARSER); - parser.setContentHandler(this.contentHandler); - parser.setLexicalHandler(this.lexicalHandler); - parser.parse(new InputSource - (new ByteArrayInputStream - (ostream.toByteArray()))); + // Extract the document using JTidy and stream it. + URL url = new URL(this.source); + org.w3c.dom.Document doc = tidy.parseDOM(new BufferedInputStream(url.openStream()), null); + DOMStreamer streamer = new DOMStreamer(this.contentHandler,this.lexicalHandler); + streamer.stream(doc); } catch (IOException e){ log.error("HTMLGenerator.generate()", e); throw(e);