cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From giac...@locus.apache.org
Subject cvs commit: xml-cocoon/src/org/apache/cocoon/generation HTMLGenerator.java
Date Mon, 30 Oct 2000 18:51:27 GMT
giacomo     00/10/30 10:51:27

  Modified:    src/org/apache/cocoon/generation Tag: xml-cocoon2
                        HTMLGenerator.java
  Log:
  New version
  
  - Cleaned up code
  - Use BufferedInputStream and BufferedOutputStream
  - Added FIXME with details of what needs to be done
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +55 -51    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.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- HTMLGenerator.java	2000/10/27 20:58:03	1.1.2.1
  +++ HTMLGenerator.java	2000/10/30 18:51:25	1.1.2.2
  @@ -1,55 +1,59 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        *
  - * ------------------------------------------------------------------------- *
  - * This software is published under the terms of the Apache Software License *
  - * version 1.1, a copy of which has been included  with this distribution in *
  - * the LICENSE file.                                                         *
  - *****************************************************************************/
  -package org.apache.cocoon.generation;
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        *
  + * ------------------------------------------------------------------------- *
  + * This software is published under the terms of the Apache Software License *
  + * version 1.1, a copy of which has been included  with this distribution in *
  + * the LICENSE file.                                                         *
  + *****************************************************************************/
  +package org.apache.cocoon.generation;
  +
  +import org.apache.avalon.Poolable;
  +import org.apache.cocoon.components.parser.Parser;
  +import org.apache.cocoon.Roles;
  +import org.xml.sax.SAXException;
  +import org.xml.sax.InputSource;
   
  -import org.apache.avalon.Poolable;
  -import java.io.IOException;
  -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;
  -
   import java.net.URL;
  -import java.io.ByteArrayInputStream;
  -import java.io.ByteArrayOutputStream;
  -
  -import org.w3c.dom.Document;
  -
  -/**
  - *
  - * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/10/27 20:58:03 $
  - */
  -public class HTMLGenerator extends ComposerGenerator implements Poolable {
  -
  -    /**
  -     * Generate XML data.
  -     */
  -    public void generate()
  -    throws IOException, SAXException {
  -        ByteArrayOutputStream ostream = new ByteArrayOutputStream();
  +import java.io.IOException;
  +import java.io.ByteArrayInputStream;
  +import java.io.ByteArrayOutputStream;
  +import java.io.BufferedInputStream;
  +import java.io.BufferedOutputStream;
  +
  +import org.w3c.tidy.Tidy;
  +
  +/**
  + *
  + * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/10/30 18:51:25 $
  + */
  +public class HTMLGenerator extends ComposerGenerator implements Poolable {
  +    /**
  +     * Generate XML data.
  +     */
  +    public void generate()
  +    throws IOException, SAXException {
           URL url = new URL(this.source);
  +        ByteArrayOutputStream ostream = new ByteArrayOutputStream();
  +
  +        // 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));
  +
  +        // 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())));
  +    }    
  +}
   
  -        // Get a spruced up document.
  -        org.w3c.tidy.Tidy tidy = new org.w3c.tidy.Tidy();
  -        System.out.println(">>>> Opening URL: " + url.toString());
  -        tidy.setXmlOut(true);
  -        tidy.setXHTML(true);
  -		Document newdoc = tidy.parseDOM(url.openStream(),ostream);
  -
  -        byte[] bytes = ostream.toByteArray();
  -
  -        // 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(bytes)));
  -    }    
  -}
  
  
  

Mime
View raw message