I never got the logger to work. I hope that you post your solution.
It looks like there are errors in the documentation. I read it several times.
There was a change to avalon's logger. Then you can add your own via the LogKit.
I tried it several ways.
I get a mismatch in the Logger class and LogKitLogger.

public LogKitLogger log = null;

JavaCompile.default <CompileJava>FopService.service
MyFop.java:197: incompatible types
found : org.apache.log.Logger
required: org.apache.avalon.framework.logger.LogKitLogger
log = Hierarchy.getDefaultHierarchy().getLoggerFor("fop");

public void setMyLogger() {
log = Hierarchy.getDefaultHierarchy().getLoggerFor("fop"); // incompatible types
logger.setPriority( Priority.DEBUG );
logger.debug( "This is a debug message" );
Hierarchy hierarchy = Hierarchy.getDefaultHierarchy();
PatternFormatter formatter = new PatternFormatter(
"[%{priority}]: %{message}\n%{throwable}" );

LogTarget target = null;
target = new StreamTarget(System.out, formatter);

hierarchy.setDefaultLogTarget(target);
log = hierarchy.getLoggerFor("fop");
log.setPriority(Priority.INFO);
NSSystem.log("Logger is not set problem with logger compile");
}
On Wednesday, September 18, 2002, at 06:59 AM, Amin Schoeib wrote:

Hi,
I tried the code of JohnPT.
Here the result:
When I compile it, I become the following error:
 
"PdfRenderer.java": Error #: 300 : method setLogger(org.apache.log.Logger) not found in class org.apache.fop.apps.Driver at line 94, column 11
To make the code running I took out the line with setLogger.

The code compiled succesfully, but when I execute it I become the following:
 
[ERROR] Logger not set
 
[INFO] building formatting object tree
 
[WARNING] Screen logger not set.
 
javax.xml.transform.TransformerException
 
 at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:725)
 
 at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:426)
 
 at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:215)
 
 at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2324)
 
 at org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(TransformerImpl.java:2147)
 
 at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1203)
 
 at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:665)
 
 at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1119)
 
 at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1097)
 
 at beraterfondsdaten.PdfRenderer.run(PdfRenderer.java:105)
 
 at beraterfondsdaten.PdfRenderer.run(PdfRenderer.java:69)
 
 at beraterfondsdaten.PdfRenderer.run(PdfRenderer.java:122)
 
 at beraterfondsdaten.Trans.main(Trans.java:9)
 
---------
 
Could not print stack trace...
 
---------
 
java.lang.NullPointerException
 
 at org.apache.fop.fo.flow.Flow.setFlowName(Unknown Source)
 
 at org.apache.fop.fo.flow.Flow.<init>(Unknown Source)
 
 at org.apache.fop.fo.flow.Flow$Maker.make(Unknown Source)
 
 at org.apache.fop.fo.FOTreeBuilder.startElement(Unknown Source)
 
 at org.apache.xalan.transformer.ResultTreeHandler.flushElem(ResultTreeHandler.java:858)
 
 at org.apache.xalan.transformer.ResultTreeHandler.flushPending(ResultTreeHandler.java:952)
 
 at org.apache.xalan.transformer.ResultTreeHandler.endElement(ResultTreeHandler.java:306)
 
 at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:716)
 
 at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:426)
 
 at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:215)
 
 at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2324)
 
 at org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(TransformerImpl.java:2147)
 
 at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1203)
 
 at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:665)
 
 at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1119)
 
 at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1097)
 
 at beraterfondsdaten.PdfRenderer.run(PdfRenderer.java:105)
 
 at beraterfondsdaten.PdfRenderer.run(PdfRenderer.java:69)
 
 at beraterfondsdaten.PdfRenderer.run(PdfRenderer.java:122)
 
 at beraterfondsdaten.Trans.main(Trans.java:9)
 
I don't understand that, I use the newest versions of FOP,XALAN,XERXES nd JAXP but it don't want to work.
What reason can this errors have?
 
thanxx
 
Schoeib


-----Ursprüngliche Nachricht-----
Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Gesendet: Dienstag, 17. September 2002 16:31
An: [EMAIL PROTECTED]
Betreff: Re: AW: AW: Embedding FOP in Java


I created a convenience class called PdfRenderer.  It cache's a stylesheet and then you can process files or streams throught it.  You can also pass parameters to your stylesheet with a hashtable (probably should have been a Hashmap).  Anyway, it's not perfect, but it works and the class file shows exactly what classes and packages are needed.

// you can call the class on xml files with the following 2 lines of code
PdfRenderer render = new PdfRenderer( "myxslfile.xsl" );
render.run("input.xml", "output.pdf");

// or if you are building a xml string in memory you can do something like the following
String xmlString = "<tag>some kind of xml</tag>";
Source strSource = new StreamSource( new StringReader(xmlString) );
OutputStream out = new FileOutputStream("outputstream.pdf");
render.run( strSource, out );

// or if you have a DOM object you can do something like the following
Hashtable xslParams = new Hashtable(2);
xslParams.put( "parameter1", "value1" );
xslParams.put( "parameter2", "value2" );
Source source = new DOMSource( node );
render.run( source, new FileOutputStream( "dom.pdf" ), xslParams );

// configs are done globally (statically) so you can call your config file anytime before the run statements
File userConfigFile = new File( "userconfig.xml" );
org.apache.fop.apps.Options options = new org.apache.fop.apps.Options( userConfigFile );

Hope that helps.  This class cleaned up a bunch of my code.

JohnPT






Hi,
Can somebody please post a working example of an embedding FOP example
with java.
I need an example which can transform directly with a XML-File and and
XSL-File into PDF.
Please post also the needed jar-Files.

Thanxx

Schoeib

-----Ursprüngliche Nachricht-----
Von: Li, Francis [mailto:[EMAIL PROTECTED]]
Gesendet: Dienstag, 17. September 2002 14:29
An: '[EMAIL PROTECTED]'
Betreff: RE: AW: Embedding FOP in Java


We use latest XALAN and latest FOP to generate HTML and PDF document.
Since we like to use latest version of XALAN and XERCES. We just pass
the FO file to FOP to handle PDF generation. We are able to use
everything new, no problem.


avalon-framework-20022706.jar
batik.jar
BCEL.jar
fop-0.20.4.jar
jaf-1.0.2.jar
jakarta-oro-2.0.4.jar
javamail-1.3.jar
java_cup.jar
log4j-1.2.6.jar
runtime.jar
xalan-2.4.0.jar
xercesImpl-2.1.0.jar
xml-apis.jar
xsltc.jar


good luck.




-----Original Message-----
From: Amin Schoeib [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 17, 2002 7:22 AM
To: [EMAIL PROTECTED]
Subject: AW: AW: Embedding FOP in Java


Hi,
I tried it also with adding the xml-apis.jar, but I become the same
error. I use the newest version of FOP,XALAN and XERXES. What other
things can make problems??

Thanxx

Schoeib

-----Ursprüngliche Nachricht-----
Von: Christian Geisert [mailto:[EMAIL PROTECTED]]
Gesendet: Dienstag, 17. September 2002 12:52
An: [EMAIL PROTECTED]
Betreff: Re: AW: Embedding FOP in Java


Amin Schoeib schrieb:
> Hi,
> I already use the newest version of XALAN.
> I use the following jar-files in my classpath:
>
> avalon-framework-cvs-20020315.jar
> batik.jar
> fop.jar
> xalan.jar
> xercesImpl.jar
>
> Are these the correct jar-files which I have to put in my classpath??

xml-apis.jar seems to be missing.

But I can't tell you if the versions are correct
and it also depends which FOP version you are using.

Christian


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]



Reply via email to