dims 00/12/04 05:10:50
Modified: src/org/apache/cocoon/generation Tag: xml-cocoon2
FileGenerator.java HTMLGenerator.java
Log:
Patches from Carsten for exception handling.
Revision Changes Path
No revision
No revision
1.1.2.11 +2 -1
xml-cocoon/src/org/apache/cocoon/generation/Attic/FileGenerator.java
Index: FileGenerator.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/generation/Attic/FileGenerator.java,v
retrieving revision 1.1.2.10
retrieving revision 1.1.2.11
diff -u -r1.1.2.10 -r1.1.2.11
--- FileGenerator.java 2000/11/15 13:59:44 1.1.2.10
+++ FileGenerator.java 2000/12/04 13:10:47 1.1.2.11
@@ -20,7 +20,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
* (Apache Software Foundation, Exoffice Technologies)
- * @version CVS $Revision: 1.1.2.10 $ $Date: 2000/11/15 13:59:44 $
+ * @version CVS $Revision: 1.1.2.11 $ $Date: 2000/12/04 13:10:47 $
*/
public class FileGenerator extends ComposerGenerator implements Poolable {
@@ -42,6 +42,7 @@
throw(e);
} catch (Exception e){
log.error("Could not get parser", e);
+ throw new ProcessingException(e.getMessage());
}
}
}
1.1.2.3 +45 -33
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.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- HTMLGenerator.java 2000/10/30 18:51:25 1.1.2.2
+++ HTMLGenerator.java 2000/12/04 13:10:48 1.1.2.3
@@ -9,51 +9,63 @@
import org.apache.avalon.Poolable;
import org.apache.cocoon.components.parser.Parser;
+import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.Roles;
+
import org.xml.sax.SAXException;
import org.xml.sax.InputSource;
-
-import java.net.URL;
-import java.io.IOException;
+
+import java.net.URL;
+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;
-
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+
+import org.w3c.tidy.Tidy;
+
/**
- *
* @author <a href="mailto:[EMAIL PROTECTED]">Davanum Srinivas</a>
- * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/10/30 18:51:25 $
+ * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/12/04 13:10:48 $
*/
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())));
+ throws IOException, SAXException, ProcessingException {
+ try
+ {
+ 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));
+
+ 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())));
+ } catch (IOException e){
+ throw(e);
+ } catch (SAXException e){
+ throw(e);
+ } catch (Exception e){
+ log.error("Could not get parser", e);
+ throw new ProcessingException(e.getMessage());
+ }
}
}
-
+
\ No newline at end of file