You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2003/12/23 11:27:04 UTC
cvs commit: cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/generation JellyGenerator.java
cziegeler 2003/12/23 02:27:04
Modified: src/blocks/scratchpad/mocks/org/apache/commons/jelly
XMLOutput.java
src/blocks/scratchpad/java/org/apache/cocoon/generation
JellyGenerator.java
Log:
JellyGenerator: Directly stream sax events instead of reparsing
Revision Changes Path
1.2 +8 -6 cocoon-2.1/src/blocks/scratchpad/mocks/org/apache/commons/jelly/XMLOutput.java
Index: XMLOutput.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/scratchpad/mocks/org/apache/commons/jelly/XMLOutput.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XMLOutput.java 4 Sep 2003 12:42:44 -0000 1.1
+++ XMLOutput.java 23 Dec 2003 10:27:04 -0000 1.2
@@ -50,7 +50,9 @@
package org.apache.commons.jelly;
import java.io.IOException;
-import java.io.Writer;
+
+import org.xml.sax.ContentHandler;
+import org.xml.sax.ext.LexicalHandler;
/**
* Mock class providing the declarations required to compile the Cocoon code when
@@ -63,11 +65,11 @@
public XMLOutput() {
}
- public void flush() throws IOException {
+ public XMLOutput(ContentHandler contentHandler,
+ LexicalHandler lexicalHandler) {
}
-
- public static XMLOutput createXMLOutput(Writer writer) {
- return null;
+
+ public void flush() throws IOException {
}
}
1.3 +1 -14 cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/generation/JellyGenerator.java
Index: JellyGenerator.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/generation/JellyGenerator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JellyGenerator.java 24 Sep 2003 22:34:53 -0000 1.2
+++ JellyGenerator.java 23 Dec 2003 10:27:04 -0000 1.3
@@ -51,8 +51,6 @@
package org.apache.cocoon.generation;
import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
import java.util.Enumeration;
import java.util.Map;
@@ -65,8 +63,6 @@
import org.apache.commons.jelly.JellyContext;
import org.apache.commons.jelly.XMLOutput;
import org.apache.excalibur.source.Source;
-import org.apache.excalibur.xml.sax.SAXParser;
-import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/**
@@ -109,7 +105,6 @@
* Generate XML data from Jelly script.
*/
public void generate() throws IOException, SAXException, ProcessingException {
- SAXParser parser = null;
Source scriptSource = null;
try {
@@ -119,28 +114,20 @@
this.updateContext();
// Execute Jelly script
- StringWriter output = new StringWriter();
- XMLOutput xmlOutput = XMLOutput.createXMLOutput(output);
+ XMLOutput xmlOutput = new XMLOutput(this.contentHandler, this.lexicalHandler);
scriptSource = this.resolver.resolveURI(this.source);
this.jellyContext.runScript(scriptSource.getURI(), xmlOutput);
xmlOutput.flush();
- InputSource inputSource = new InputSource(new StringReader(output.toString()));
- parser = (SAXParser) this.manager.lookup(SAXParser.ROLE);
- parser.parse(inputSource, super.xmlConsumer);
} catch (IOException e) {
getLogger().error("JellyGenerator.generate()", e);
throw new ResourceNotFoundException("JellyGenerator could not find resource", e);
- } catch (SAXException e) {
- getLogger().error("JellyGenerator.generate()", e);
- throw (e);
} catch (Exception e) {
getLogger().error("Could not get parser", e);
throw new ProcessingException("Exception in JellyGenerator.generate()", e);
} finally {
this.resolver.release( scriptSource );
- this.manager.release(parser);
}
}