aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/java/org/apache/fop/apps/AWTStarter.java11
-rw-r--r--src/java/org/apache/fop/apps/CommandLineOptions.java2
-rw-r--r--src/java/org/apache/fop/apps/CommandLineStarter.java11
-rw-r--r--src/java/org/apache/fop/apps/Driver.java13
-rw-r--r--src/java/org/apache/fop/apps/InputHandler.java18
-rw-r--r--src/java/org/apache/fop/apps/PrintStarter.java10
-rw-r--r--src/java/org/apache/fop/apps/Starter.java21
-rw-r--r--src/java/org/apache/fop/tools/TestConverter.java18
-rw-r--r--src/java/org/apache/fop/tools/anttasks/Fop.java8
9 files changed, 36 insertions, 76 deletions
diff --git a/src/java/org/apache/fop/apps/AWTStarter.java b/src/java/org/apache/fop/apps/AWTStarter.java
index 57515a6cb..caf6bd39b 100644
--- a/src/java/org/apache/fop/apps/AWTStarter.java
+++ b/src/java/org/apache/fop/apps/AWTStarter.java
@@ -62,9 +62,6 @@ import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Locale;
-// SAX
-import org.xml.sax.XMLReader;
-
/**
* AWT Viewer starter.
* Originally contributed by:
@@ -77,7 +74,6 @@ public class AWTStarter extends CommandLineStarter {
private PreviewDialog frame;
private Translator translator;
private Driver driver;
- private XMLReader parser;
/**
* Construct an AWTStarter
@@ -103,11 +99,6 @@ public class AWTStarter extends CommandLineStarter {
renderer.setComponent(frame);
driver = new Driver();
driver.setRenderer(renderer);
- parser = inputHandler.getParser();
- if (parser == null) {
- throw new FOPException("Unable to create SAX parser");
- }
- setParserFeatures(parser);
}
/**
@@ -118,7 +109,7 @@ public class AWTStarter extends CommandLineStarter {
driver.reset();
try {
frame.setStatus(translator.getString("Status.Build.FO.tree"));
- driver.render(parser, inputHandler.getInputSource());
+ driver.render(inputHandler);
frame.setStatus(translator.getString("Status.Show"));
frame.showPage();
} catch (Exception e) {
diff --git a/src/java/org/apache/fop/apps/CommandLineOptions.java b/src/java/org/apache/fop/apps/CommandLineOptions.java
index 653ab2158..aa66d25b5 100644
--- a/src/java/org/apache/fop/apps/CommandLineOptions.java
+++ b/src/java/org/apache/fop/apps/CommandLineOptions.java
@@ -678,7 +678,7 @@ public class CommandLineOptions {
+ " see options with \"-print help\" \n\n"
+ " [Examples]\n" + " Fop foo.fo foo.pdf \n"
+ " Fop -fo foo.fo -pdf foo.pdf (does the same as the previous line)\n"
- + " Fop -xsl foo.xsl -xml foo.xml -pdf foo.pdf\n"
+ + " Fop -xml foo.xml -xsl foo.xsl -pdf foo.pdf\n"
+ " Fop foo.fo -mif foo.mif\n"
+ " Fop foo.fo -rtf foo.rtf\n"
+ " Fop foo.fo -print or Fop -print foo.fo \n"
diff --git a/src/java/org/apache/fop/apps/CommandLineStarter.java b/src/java/org/apache/fop/apps/CommandLineStarter.java
index cdda837b3..130193018 100644
--- a/src/java/org/apache/fop/apps/CommandLineStarter.java
+++ b/src/java/org/apache/fop/apps/CommandLineStarter.java
@@ -50,9 +50,6 @@
*/
package org.apache.fop.apps;
-// SAX
-import org.xml.sax.XMLReader;
-
// Java
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
@@ -85,15 +82,9 @@ public class CommandLineStarter extends Starter {
*/
public void run() throws FOPException {
String version = Version.getVersion();
-
getLogger().info(version);
-
- XMLReader parser = inputHandler.getParser();
- setParserFeatures(parser);
-
Driver driver = new Driver();
setupLogger(driver);
- driver.initialize();
try {
driver.setRenderer(commandLineOptions.getRenderer());
@@ -105,7 +96,7 @@ public class CommandLineStarter extends Starter {
driver.getRenderer().setOptions(
commandLineOptions.getRendererOptions());
}
- driver.render(parser, inputHandler.getInputSource());
+ driver.render(inputHandler);
} finally {
bos.close();
}
diff --git a/src/java/org/apache/fop/apps/Driver.java b/src/java/org/apache/fop/apps/Driver.java
index 86c6d2206..715195bae 100644
--- a/src/java/org/apache/fop/apps/Driver.java
+++ b/src/java/org/apache/fop/apps/Driver.java
@@ -553,6 +553,19 @@ public class Driver implements LogEnabled {
}
/**
+ * Render the FO document read by a SAX Parser from an InputHandler
+ * @param InputHandler the input handler containing the source and
+ * parser information.
+ * @throws FOPException if anything goes wrong.
+ */
+ public synchronized void render(InputHandler inputHandler)
+ throws FOPException {
+ XMLReader parser = inputHandler.getParser();
+ inputHandler.setParserFeatures(parser);
+ render(parser, inputHandler.getInputSource());
+ }
+
+ /**
* Render the FO document read by a SAX Parser from an InputSource.
* @param parser the SAX parser.
* @param source the input source the parser reads from.
diff --git a/src/java/org/apache/fop/apps/InputHandler.java b/src/java/org/apache/fop/apps/InputHandler.java
index 7f7fe40a0..c9783fc13 100644
--- a/src/java/org/apache/fop/apps/InputHandler.java
+++ b/src/java/org/apache/fop/apps/InputHandler.java
@@ -136,6 +136,22 @@ public abstract class InputHandler {
* @throws FOPException if processing this InputHandler fails
*/
public abstract void run(Driver driver) throws FOPException;
-
+
+ /**
+ * Sets the parser features on an XMLReader
+ * @param parser XMLReader to set features on
+ * @throws FOPException if the XMLReader doesn't support the feature that
+ * need to be set
+ */
+ public static void setParserFeatures(XMLReader parser) throws FOPException {
+ try {
+ parser.setFeature("http://xml.org/sax/features/namespace-prefixes",
+ true);
+ } catch (SAXException e) {
+ throw new FOPException("Error: You need a parser which allows the"
+ + " http://xml.org/sax/features/namespace-prefixes"
+ + " feature to be set to true to support namespaces", e);
+ }
+ }
}
diff --git a/src/java/org/apache/fop/apps/PrintStarter.java b/src/java/org/apache/fop/apps/PrintStarter.java
index 4e242d977..e8a256bd0 100644
--- a/src/java/org/apache/fop/apps/PrintStarter.java
+++ b/src/java/org/apache/fop/apps/PrintStarter.java
@@ -59,7 +59,6 @@ package org.apache.fop.apps;
* (apparently) redundant copies code, generally cleaned up, and
* added interfaces to the new Render API.
*/
-import org.xml.sax.XMLReader;
import java.awt.print.PrinterJob;
import org.apache.fop.render.awt.AWTPrintRenderer;
@@ -88,13 +87,6 @@ public class PrintStarter extends CommandLineStarter {
public void run() throws FOPException {
Driver driver = new Driver();
- String version = Version.getVersion();
- //log.debug(version);
-
- XMLReader parser = inputHandler.getParser();
-
- setParserFeatures(parser);
-
PrinterJob pj = PrinterJob.getPrinterJob();
if (System.getProperty("dialog") != null) {
if (!pj.printDialog()) {
@@ -110,7 +102,7 @@ public class PrintStarter extends CommandLineStarter {
try {
driver.setRenderer(renderer);
- driver.render(parser, inputHandler.getInputSource());
+ driver.render(inputHandler);
} catch (Exception e) {
if (e instanceof FOPException) {
throw (FOPException)e;
diff --git a/src/java/org/apache/fop/apps/Starter.java b/src/java/org/apache/fop/apps/Starter.java
index f4b5d2ee8..676505675 100644
--- a/src/java/org/apache/fop/apps/Starter.java
+++ b/src/java/org/apache/fop/apps/Starter.java
@@ -53,10 +53,6 @@ package org.apache.fop.apps;
// Avalon
import org.apache.avalon.framework.logger.AbstractLogEnabled;
-// SAX
-import org.xml.sax.XMLReader;
-import org.xml.sax.SAXException;
-
/**
* Abstract super class.
* Creates a SAX Parser (defaulting to Xerces).
@@ -87,21 +83,4 @@ public abstract class Starter extends AbstractLogEnabled {
*/
public abstract void run() throws FOPException;
- /**
- * Sets the parser features on an XMLReader
- * @param parser XMLReader to set features on
- * @throws FOPException if the XMLReader doesn't support the feature that
- * need to be set
- */
- public void setParserFeatures(XMLReader parser) throws FOPException {
- try {
- parser.setFeature("http://xml.org/sax/features/namespace-prefixes",
- true);
- } catch (SAXException e) {
- throw new FOPException("Error: You need a parser which allows the"
- + " http://xml.org/sax/features/namespace-prefixes"
- + " feature to be set to true to support namespaces", e);
- }
- }
-
}
diff --git a/src/java/org/apache/fop/tools/TestConverter.java b/src/java/org/apache/fop/tools/TestConverter.java
index 1f8449043..bbe5cb709 100644
--- a/src/java/org/apache/fop/tools/TestConverter.java
+++ b/src/java/org/apache/fop/tools/TestConverter.java
@@ -70,8 +70,6 @@ import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.xml.sax.XMLReader;
-import org.xml.sax.SAXException;
/**
* TestConverter is used to process a set of tests specified in
@@ -287,12 +285,8 @@ public class TestConverter extends AbstractLogEnabled {
+ xsl));
}
- XMLReader parser = inputHandler.getParser();
- setParserFeatures(parser);
-
Driver driver = new Driver();
setupLogger(driver, "fop");
- driver.initialize();
FOUserAgent userAgent = new FOUserAgent();
userAgent.setBaseURL(baseURL);
driver.setUserAgent(userAgent);
@@ -316,7 +310,7 @@ public class TestConverter extends AbstractLogEnabled {
new java.io.FileOutputStream(new File(destdir,
outname + (outputPDF ? ".pdf" : ".at.xml")))));
getLogger().debug("ddir:" + destdir + " on:" + outname + ".pdf");
- driver.render(parser, inputHandler.getInputSource());
+ driver.render(inputHandler);
// check difference
if (compare != null) {
@@ -362,16 +356,6 @@ public class TestConverter extends AbstractLogEnabled {
return false;
}
- private void setParserFeatures(XMLReader parser) throws FOPException {
- try {
- parser.setFeature("http://xml.org/sax/features/namespace-prefixes",
- true);
- } catch (SAXException e) {
- throw new FOPException("Error in setting up parser feature namespace-prefixes\n"
- + "You need a parser which supports SAX version 2", e);
- }
- }
-
private Node locateResult(Node testcase, String id) {
NodeList cases = testcase.getChildNodes();
for (int count = 0; count < cases.getLength(); count++) {
diff --git a/src/java/org/apache/fop/tools/anttasks/Fop.java b/src/java/org/apache/fop/tools/anttasks/Fop.java
index a4104de92..9c3007199 100644
--- a/src/java/org/apache/fop/tools/anttasks/Fop.java
+++ b/src/java/org/apache/fop/tools/anttasks/Fop.java
@@ -58,9 +58,6 @@ import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.util.GlobPatternMapper;
-// SAX
-import org.xml.sax.XMLReader;
-
// Java
import java.io.File;
import java.io.IOException;
@@ -463,8 +460,6 @@ class FOPTaskStarter extends Starter {
private void render(File foFile, File outFile,
int renderer) throws FOPException {
InputHandler inputHandler = new FOInputHandler(foFile);
- XMLReader parser = inputHandler.getParser();
- setParserFeatures(parser);
OutputStream out = null;
try {
@@ -480,14 +475,13 @@ class FOPTaskStarter extends Starter {
try {
Driver driver = new Driver();
setupLogger(driver);
- driver.initialize();
FOUserAgent userAgent = new FOUserAgent();
userAgent.setBaseURL(this.baseURL);
userAgent.enableLogging(getLogger());
driver.setUserAgent(userAgent);
driver.setRenderer(renderer);
driver.setOutputStream(out);
- driver.render(parser, inputHandler.getInputSource());
+ driver.render(inputHandler);
} catch (Exception ex) {
throw new BuildException(ex);
} finally {