import java.awt.event.WindowEvent;
import java.util.Locale;
-// SAX
-import org.xml.sax.XMLReader;
-
/**
* AWT Viewer starter.
* Originally contributed by:
private PreviewDialog frame;
private Translator translator;
private Driver driver;
- private XMLReader parser;
/**
* Construct an AWTStarter
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);
}
/**
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) {
+ " 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"
*/
package org.apache.fop.apps;
-// SAX
-import org.xml.sax.XMLReader;
-
// Java
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
*/
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());
driver.getRenderer().setOptions(
commandLineOptions.getRendererOptions());
}
- driver.render(parser, inputHandler.getInputSource());
+ driver.render(inputHandler);
} finally {
bos.close();
}
return treeBuilder;
}
+ /**
+ * 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.
* @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);
+ }
+ }
}
* (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;
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()) {
try {
driver.setRenderer(renderer);
- driver.render(parser, inputHandler.getInputSource());
+ driver.render(inputHandler);
} catch (Exception e) {
if (e instanceof FOPException) {
throw (FOPException)e;
// 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).
*/
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);
- }
- }
-
}
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
+ 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);
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) {
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++) {
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;
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 {
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 {