diff options
author | Simon Pepping <spepping@apache.org> | 2009-10-25 11:04:11 +0000 |
---|---|---|
committer | Simon Pepping <spepping@apache.org> | 2009-10-25 11:04:11 +0000 |
commit | af822593a3e4b4b2ed008c490612d3b811b32916 (patch) | |
tree | e37039ebbb7fdcf947c439c11c64258c884e6f5e /src/java/org | |
parent | 0baeb8398f5d193ff246907bb3471132a8fb280f (diff) | |
download | xmlgraphics-fop-af822593a3e4b4b2ed008c490612d3b811b32916.tar.gz xmlgraphics-fop-af822593a3e4b4b2ed008c490612d3b811b32916.zip |
Added events to the implementation of the catalog command-line option
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@829532 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org')
4 files changed, 30 insertions, 22 deletions
diff --git a/src/java/org/apache/fop/cli/CommandLineOptions.java b/src/java/org/apache/fop/cli/CommandLineOptions.java index ad854891b..8f396c04a 100644 --- a/src/java/org/apache/fop/cli/CommandLineOptions.java +++ b/src/java/org/apache/fop/cli/CommandLineOptions.java @@ -1025,7 +1025,11 @@ public class CommandLineOptions { case IF_INPUT: return new IFInputHandler(iffile); case XSLT_INPUT: - return new InputHandler(xmlfile, xsltfile, xsltParams, useCatalogResolver); + InputHandler handler = new InputHandler(xmlfile, xsltfile, xsltParams); + if (useCatalogResolver) { + handler.createCatalogResolver(foUserAgent); + } + return handler; case IMAGE_INPUT: return new ImageInputHandler(imagefile, xsltfile, xsltParams); default: diff --git a/src/java/org/apache/fop/cli/InputHandler.java b/src/java/org/apache/fop/cli/InputHandler.java index a1ff1715b..363cd0767 100644 --- a/src/java/org/apache/fop/cli/InputHandler.java +++ b/src/java/org/apache/fop/cli/InputHandler.java @@ -51,6 +51,7 @@ import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.Fop; import org.apache.fop.apps.FopFactory; +import org.apache.fop.events.ResourceEventProducer; import org.apache.fop.render.awt.viewer.Renderable; /** @@ -64,8 +65,8 @@ public class InputHandler implements ErrorListener, Renderable { protected File sourcefile; private File stylesheet; // for XML/XSLT usage private Vector xsltParams; // for XML/XSLT usage - private EntityResolver entityResolver; - private URIResolver uriResolver; + private EntityResolver entityResolver = null; + private URIResolver uriResolver = null; /** the logger */ protected Log log = LogFactory.getLog(InputHandler.class); @@ -85,23 +86,6 @@ public class InputHandler implements ErrorListener, Renderable { } /** - * Constructor for XML->XSLT->FO input - * - * @param xmlfile XML file - * @param xsltfile XSLT file - * @param params Vector of command-line parameters (name, value, - * name, value, ...) for XSL stylesheet, null if none - * @param useCatalogResolver if true, use a catalog resolver - * for XML parsing and XSLT URI resolution - */ - public InputHandler(File xmlfile, File xsltfile, Vector params, boolean useCatalogResolver) { - this(xmlfile, xsltfile, params); - if (useCatalogResolver) { - createCatalogResolver(); - } - } - - /** * Constructor for FO input * @param fofile the file to read the FO document. */ @@ -213,10 +197,12 @@ public class InputHandler implements ErrorListener, Renderable { * Tries the Apache Commons Resolver, and if unsuccessful, * tries the same built into Java 6. */ - private void createCatalogResolver() { + public void createCatalogResolver(FOUserAgent userAgent) { String[] classNames = new String[] { "org.apache.xml.resolver.tools.CatalogResolver", "com.sun.org.apache.xml.internal.resolver.tools.CatalogResolver"}; + ResourceEventProducer eventProducer = + ResourceEventProducer.Provider.get(userAgent.getEventBroadcaster()); Class resolverClass = null; for (int i = 0; i < classNames.length && resolverClass == null; ++i) { try { @@ -226,7 +212,7 @@ public class InputHandler implements ErrorListener, Renderable { } } if (resolverClass == null) { - log.error("Could not find catalog resolver in class path"); + eventProducer.catalogResolverNotFound(this); return; } try { @@ -234,8 +220,10 @@ public class InputHandler implements ErrorListener, Renderable { uriResolver = (URIResolver) resolverClass.newInstance(); } catch (InstantiationException e) { log.error("Error creating the catalog resolver: " + e.getMessage()); + eventProducer.catalogResolverNotCreated(this, e.getMessage()); } catch (IllegalAccessException e) { log.error("Error creating the catalog resolver: " + e.getMessage()); + eventProducer.catalogResolverNotCreated(this, e.getMessage()); } } diff --git a/src/java/org/apache/fop/events/EventFormatter.xml b/src/java/org/apache/fop/events/EventFormatter.xml index 147744a0d..84e3883f8 100644 --- a/src/java/org/apache/fop/events/EventFormatter.xml +++ b/src/java/org/apache/fop/events/EventFormatter.xml @@ -79,6 +79,8 @@ Any reference to it will be considered a reference to the first occurrence in th <message key="org.apache.fop.events.ResourceEventProducer.foreignXMLNoHandler">Some XML content will be ignored. No handler defined for XML with namespace "{namespaceURI}".</message> <message key="org.apache.fop.events.ResourceEventProducer.imageWritingError">Error while writing an image to the target file.[ Reason: {e}]</message> <message key="org.apache.fop.events.ResourceEventProducer.cannotDeleteTempFile">Temporary file could not be deleted: {tempFile}</message> + <message key="org.apache.fop.events.ResourceEventProducer.catalogResolverNotFound">Catalog resolver not found along the classpath</message> + <message key="org.apache.fop.events.ResourceEventProducer.catalogResolverNotCreated">Error creating the catalog resolver: {message}</message> <message key="org.apache.fop.layoutmgr.inline.InlineLevelEventProducer.leaderWithoutContent">fo:leader is set to "use-content" but has no content.{{locator}}</message> <message key="org.apache.fop.layoutmgr.inline.InlineLevelEventProducer.lineOverflows">Line {line} of a paragraph overflows the available area by {overflowLength,choice,50000#{overflowLength} millipoints|50000<more than 50 points}.{{locator}}</message> <message key="org.apache.fop.layoutmgr.BlockLevelEventProducer.rowTooTall">The contents of table-row {row} are taller than they should be (there is a block-progression-dimension or height constraint on the indicated row). Due to its contents the row grows to {effCellBPD} millipoints, but the row shouldn't get any taller than {maxCellBPD} millipoints.{{locator}}</message> diff --git a/src/java/org/apache/fop/events/ResourceEventProducer.java b/src/java/org/apache/fop/events/ResourceEventProducer.java index 607d2fab1..3753e83da 100644 --- a/src/java/org/apache/fop/events/ResourceEventProducer.java +++ b/src/java/org/apache/fop/events/ResourceEventProducer.java @@ -133,4 +133,18 @@ public interface ResourceEventProducer extends EventProducer { */ void cannotDeleteTempFile(Object source, File tempFile); + /** + * Catalog Resolver not found along the class path + * @param source the event source + * @event.severity ERROR + */ + void catalogResolverNotFound(Object source); + + /** + * Catalog Resolver not created, due to InstantiationException or IllegalAccessException + * @param source the event source + * @param message the exception message + * @event.severity ERROR + */ + void catalogResolverNotCreated(Object source, String message); } |