I have created a htm page..
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<P> </P>
<!-- Insert HTML here -->
<APPLET style="LEFT: 0px; TOP: 0px" height=200 width=320
code=IESPrint.class name=IESPrint VIEWASTEXT>
<PARAM NAME="label" VALUE="This string was passed from the HTML
host."></APPLET>
</BODY>
</HTML>
containing an applet..
//Java
import java.awt.*;
import java.applet.*;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
//JAXP
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerException;
import javax.xml.transform.Source;
import javax.xml.transform.Result;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.sax.SAXResult;
//Avalon
import org.apache.avalon.framework.ExceptionUtil;
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.avalon.framework.logger.Logger;
//FOP
import org.apache.fop.apps.Driver;
import org.apache.fop.apps.FOPException;
import org.apache.fop.messaging.MessageHandler;
/**
* This class reads PARAM tags from its HTML host page and sets
* the color and label properties of the applet. Program execution
* begins with the init() method.
*/
public class IESPrint extends Applet
{
/**
* The entry point for the applet.
*/
public void init()
{
initForm();
usePageParams();
try
{
System.out.println("FOP ExampleXML2PDF\n");
System.out.println("Preparing...");
//Setup input and output files
File xmlfile = new File("tsectionprint.xml");
File xsltfile = new File(" tsectionprint.xsl");
File pdffile = new File("oi.pdff");
// File xmlfile = new File(args[0]);
// File xsltfile = new File(args[1]);
// File pdffile = new File(args[2]);
System.out.println("Input: XML (" + xmlfile + ")");
System.out.println("Stylesheet: " + xsltfile);
System.out.println("Output: PDF (" + pdffile + ")");
System.out.println();
System.out.println("Transforming...");
IESPrint app = new IESPrint();
app.convertXML2PDF(xmlfile, xsltfile, pdffile);
System.out.println("Success!");
}
catch (Exception e)
{
System.err.println(ExceptionUtil.printStackTrace(e));
System.exit(-1);
}
// TODO: Add any constructor code after initForm call.
}
private final String labelParam = "label";
/**
* Reads parameters from the applet's HTML host and sets applet
* properties.
*/
private void usePageParams()
{
final String defaultLabel = "Default label";
String labelValue;
labelValue = getParameter(labelParam);
if ((labelValue == null))
{
/**
* There was something wrong with the HTML host tags.
* Generate default values.
*/
labelValue = defaultLabel;
}
/**
* Set the applet's string label, background color, and
* foreground colors.
*/
label1.setText(labelValue);
}
/**
* External interface used by design tools to show properties of an
applet.
*/
public String[][] getParameterInfo()
{
String[][] info =
{
{ labelParam, "String", "Label string to be displayed"
},
};
return info;
}
Label label1 = new Label();
/**
* Intializes values for the applet and its components
*/
void initForm()
{
label1.setText("label1");
this.setLayout(new BorderLayout());
this.add("North",label1);
}
public void convertXML2PDF(File xml, File xslt, File pdf)
throws IOException, FOPException, TransformerException
{
//Construct driver
Driver driver = new Driver();
//Setup logger
Logger logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
driver.setLogger(logger);
MessageHandler.setScreenLogger(logger);
//Setup Renderer (output format)
driver.setRenderer(Driver.RENDER_PDF);
//Setup output
OutputStream out = new java.io.FileOutputStream(pdf);
try
{
driver.setOutputStream(out);
//Setup XSLT
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new
StreamSource(xslt));
//Setup input for XSLT transformation
Source src = new StreamSource(xml);
//Resulting SAX events (the generated FO) must be piped through
to FOP
Result res = new SAXResult(driver.getContentHandler());
//Start XSLT transformation and FOP processing
transformer.transform(src, res);
}
finally
{
out.close();
}
}
}
I have the FOP .jar files in win2k\java\class...
I have the Sun JRE installed with the IE6 plugin
When I access the htm page I get 'Applet notinited' error and the console
displays..
java.lang.NoClassDefFoundError: org/apache/avalon/framework/logger/Logger
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:1590)
at java.lang.Class.getConstructor0(Class.java:1762)
at java.lang.Class.newInstance0(Class.java:276)
at java.lang.Class.newInstance(Class.java:259)
at sun.applet.AppletPanel.createApplet(AppletPanel.java:566)
at sun.plugin.AppletViewer.createApplet(AppletViewer.java:1775)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:495)
at sun.applet.AppletPanel.run(AppletPanel.java:292)
at java.lang.Thread.run(Thread.java:536)
Matthew Lancashire
IT Project Manager
Intitial Electronic Security Ltd
Tel: +44 1282 473554
Fax: +44 1254 267552
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]