maverick-opt-fop with fop-0.20.5rc3a

"Eelco Hillenius" <[email protected]>
Newsgroups gmane.comp.web.maverick.general
Message-ID <000a01c32ea6$9ef040a0$01a8a8c0@Eelco>
Hi all,

When using the latest version of FOP (which is the only version that behaves
really well with my system) I came across some API changes that breaks
FopTransform from maverick-opt-fop.

1. Options are now only supported for command line operations;
2. The Avalon logger now must be set with 'driver.setLogger(log)' instead of
'MessageHandler.setScreenLogger(log)'.

I do not think 'options' is supported in any other way now; I could not find
any docs about it (though I didn't search the mailing list. As it not really
encouraged anyway, imho it's best to just discard it.

I've included a path that works with both the older (4) and the 5rc3a
versions of FOP. I do not set a logger though (but have the 5rc3a version as
a comment), as one of the methods breaks one of the versions. If not set,
the default (screen-) logger will be used.

Eelco
patch.txt (text/plain, 3.3 KB)
Index: FopTransform.java
===================================================================
RCS file: /cvsroot/mav/opt-fop/src/java/org/infohazard/maverick/opt/transform/FopTransform.java,v
retrieving revision 1.11
diff -u -r1.11 FopTransform.java
--- FopTransform.java	7 Aug 2002 18:03:05 -0000	1.11
+++ FopTransform.java	9 Jun 2003 16:35:29 -0000
@@ -2,12 +2,10 @@
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.io.File;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.Reader;
-import java.io.StringReader;
 import java.io.StringWriter;
 
 import javax.servlet.ServletConfig;
@@ -28,9 +26,8 @@
 import org.apache.avalon.framework.logger.Log4JLogger;
 import org.apache.fop.apps.Driver;
 import org.apache.fop.apps.FOPException;
-import org.apache.fop.apps.Options;
-import org.apache.fop.messaging.MessageHandler;
 import org.apache.log4j.Category;
+
 import org.infohazard.maverick.flow.ConfigException;
 import org.infohazard.maverick.flow.Transform;
 import org.infohazard.maverick.flow.TransformContext;
@@ -41,7 +38,9 @@
 import org.xml.sax.ContentHandler;
 import org.xml.sax.InputSource;
 
-
+/**
+ * This Transform runs the input (XSL:FO) through the apache FOP processor
+ */
 public class FopTransform implements Transform
 {
 
@@ -51,7 +50,6 @@
 	protected static final String ATTR_OUTPUT = "output";
 	protected static final String ATTR_DISPOSITION_TYPE = "disposition-type";
 	protected static final String ATTR_FILENAME = "filename";
-	protected static final String ATTR_CONFIG = "config";
 	
 	protected TransformerFactory tFactory = TransformerFactory.newInstance();
 
@@ -64,23 +62,15 @@
 	 */
 	protected String filename;
 
-	
-	protected String configPath = null;
-
-	public FopTransform(Element transformNode, ServletConfig servletCfg) throws ConfigException
-	
+	public FopTransform(Element transformNode, ServletConfig servletCfg) 
+			throws ConfigException
 	{
 		this.setOutput(XML.getValue(transformNode, ATTR_OUTPUT));
 		this.filename = XML.getValue(transformNode, ATTR_FILENAME);
-
-		String path = XML.getValue(transformNode, ATTR_CONFIG);
-		if (path!=null)
-		{
-			this.configPath = servletCfg.getServletContext().getRealPath(path);
-		}
 	}
 
-	public void setOutput(String output) throws ConfigException {
+	public void setOutput(String output) throws ConfigException 
+	{
 		if (output != null)
 		{
 			if (output.equalsIgnoreCase("pdf"))
@@ -248,24 +238,14 @@
 		private void go(InputSource input) throws IOException, ServletException
 		{
 			ByteArrayOutputStream baos = new ByteArrayOutputStream();
-			Log4JLogger dlog = new Log4JLogger(fopDriverLog);
-			MessageHandler.setScreenLogger(dlog);
-			
 			try
 			{
-				Options options = null;
-
-				//load userconfig file if specified
-				if (configPath != null)
-				{
-					//load the user config file if specified
-					options = new Options(new File(configPath));
-				} else {
-					//try and load the standard options off of the classpath
-					options = new Options();
-				}
 				Driver driver = new Driver(input, baos);
-				driver.setLogger(dlog);
+				Log4JLogger dlog = new Log4JLogger(fopDriverLog);
+				
+				// works with fop-0.20.5rc3a
+				//driver.enableLogging(dlog);
+				
 				driver.setRenderer(output);
 				driver.run();
 			}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.