RE: FOP WARNING - Please Help!

2001-09-26 Thread Savino, Matt C

I downloaded and built the latest CVS. When I tried to use the
XSLTInputHandler, my error switched from the weird one I was getting to yet
another null pointer exception. That got me thinking maybe I should just try
doing the simplest transform of all time and see if it isn't something with
my stylesheet. Anyway the problem was I only had the xsl namespace defined
in my stylesheet root element and not the fo namespace.

xsl:stylesheet 
xmlns:xsl=http://www.w3.org/1999/XSL/Transform; version=1.0
xmlns:fo=http://www.w3.org/1999/XSL/Format;   (missing)


I probably should have known this. I think someone even mentioned it, but I
wasn't sure what they were talking about. Anyway, the good news is that
after three days of fiddling I feel like I know FOP pretty well. I also have
a much better grasp of SAX and DOM.

Again, thanks for all your help. You probably haven't heard the last of me.

-Matt Savino


-Original Message-
From: Beer, Christian [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 25, 2001 11:32 PM
To: '[EMAIL PROTECTED]'
Subject: AW: FOP WARNING - Please Help!


I had the same problem with the 0.20.1 release. Try using the actual
cvs version. There it works!

Christian

-Ursprüngliche Nachricht-
Von: Savino, Matt C [mailto:[EMAIL PROTECTED]]
Gesendet: Mittwoch, 26. September 2001 01:37
An: '[EMAIL PROTECTED]'
Betreff: RE: FOP WARNING - Please Help!


(I just realize this message might be pretty hard to read, so I added 
at the beginning and end of code and error blocks.)

Shkuro, I have tried to replicate your solution and I still get strange
errors. Here is the error I get:


D:\Precision\RV40_Working\pvhjava FOtoPDF
building formatting object tree
building formatting object tree
javax.xml.transform.TransformerException
at
org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.j
ava:1212)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:
479)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:
1118)
at FOtoPDF.applyFop(FOtoPDF.java:143)
at FOtoPDF.main(FOtoPDF.java:41)
-
java.lang.NullPointerException
at
org.apache.fop.fo.FOTreeBuilder.startDocument(FOTreeBuilder.java:167)
at
org.apache.xalan.transformer.QueuedStartDocument.flush(QueuedStartDocument.j
ava:108)
at
org.apache.xalan.transformer.ResultTreeHandler.flushPending(ResultTreeHandle
r.java:758)
at
org.apache.xalan.transformer.ResultTreeHandler.startElement(ResultTreeHandle
r.java:245)
at
org.apache.xalan.transformer.ResultTreeHandler.startElement(ResultTreeHandle
r.java:209)
at
org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:
704)
at
org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Transform
erImpl.java:2154)
at
org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Transform
erImpl.java:2097)
at
org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(Transformer
Impl.java:2029)
at
org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.j
ava:1189)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:
479)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:
1118)
at FOtoPDF.applyFop(FOtoPDF.java:143)
at FOtoPDF.main(FOtoPDF.java:41)


It looks like maybe it's trying to build the formatting tree twice? 

Here is my code:

DocumentBuilderFactory dFactory =
DocumentBuilderFactory.newInstance();
dFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dFactory.newDocumentBuilder();

org.w3c.dom.Document xmlDoc = dBuilder.parse(xmlFilename);
DOMSource xmlDomSource = new DOMSource(xmlDoc);

org.w3c.dom.Document xslDoc = dBuilder.parse(xslFilename);
DOMSource xslDomSource = new DOMSource(xslDoc);

TransformerFactory tFactory = TransformerFactory.newInstance();
javax.xml.transform.Templates templates =
tFactory.newTemplates(xslDomSource);
Transformer transformer = templates.newTransformer();

org.apache.fop.apps.Driver driver = new
org.apache.fop.apps.Driver();
driver.setErrorDump(true);
driver.setRenderer(driver.RENDER_PDF);
driver.setOutputStream(new FileOutputStream(pdfFilename));

javax.xml.transform.sax.SAXResult saxResult = new
javax.xml.transform.sax.SAXResult( driver.getContentHandler() );
transformer.transform(xmlDomSource, saxResult);


Someone also said this may be fixed in the latest CVS. I downloaded
Fop-0.20.1-src.tar.gz on 9/17/01. Is there something more recent? I only ask
because my ridiculous company still hasn't restored our internet access
since Nimda.

I would also be happy if I could get render(dom) working when applied

FOP WARNING

2001-09-24 Thread Amit

I am trying to generate PDFs using FOP-0.20.1. The input files are xml
and xsl files
I am using JRun3.0 with java1.2.2

Here is the error I get

WARNING: Unknown formatting object ^root

Anybody any ideas?




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




Re: FOP WARNING

2001-09-24 Thread Semprini Davide



Hi,

I want explain that the error:
WARNING: Unknown formatting object ^root
for me is locate in stylesheet
Instead the error that 
Ihave encountered it was on my XML
I think that the parser didn't know my element root!
For this reason I haven't used the code in fop home
and I have perform first the transformation
and then the driver

Bye

D.Semprini











Semprini Davide wrote:
[EMAIL PROTECTED]">   Hi,
  
 I have had the same problem
 Nobody give me a response! 
  
 This code in FOP Home page don't work (for me!) !
  Driver driver = new Driver();  driver.setRenderer(Driver.RENDER_PDF);  InputHandler inputHandler = new XSLTInputHandler(xmlFile, xslFile);  XMLReader parser = inputHandler.getParser();  driver.setOutputStream(new FileOutputStream(outFile));  driver.render(parser, inputHandler.getInputSource());
  
 I have solved the problem using 2 phase:
  
 1) generate the transformation using XSLTrasform, Xalan1Transform etc... 
(you can choose)
 code:
  
 XSLTransform traXSLT = new XSLTransform();
 traXSLT.transform(urlXML, urlXSL, urlFoFile);
  
 You can choose 4 transform type (see the api documentation)
  
 2) Apply the result at the driver
  
 FileInputStream file = new FileInputStream(urlFoFile);
  
  response.setContentType("application/pdf");
  
  Driver driver = new Driver(new InputSource(file), out);
  driver.setRenderer(Driver.RENDER_PDF);
  driver.run();
  byte[] content = out.toByteArray();
  response.setContentLength(content.length);
  response.getOutputStream().write(content);
  response.getOutputStream().flush();
  
 THIS CODE WORK FINE!!!
  
 Bye
  
 
  
 Amit wrote:
  [EMAIL PROTECTED]">
I am trying to generate PDFs using FOP-0.20.1. The input files are xmland xsl filesI am using JRun3.0 with java1.2.2Here is the error I getWARNING: Unknown formatting object ^rootAnybody any ideas?-To unsubscribe, e-mail: [EMAIL PROTECTED]For additional commands, email: [EMAIL PROTECTED]








Re: FOP WARNING

2001-09-24 Thread Semprini Davide



Okay,

The example that I give is only to explain
that you can perform the PDF in two distinc phase
1) perform a trasformation 
2) use driver

You can use the "tranform method" 
with input like Dynamic xml (Dom Document) or urlXML 
and getting out a fo (Dom Document) or Writer object
YOU HAVE A LOT OF TRANSFORM TO USE!!
YOU HAVE TO SEE THE APIDOC FOR THE
COMPLETE DOCUMENTATION

For example in my project I use
xalan transform and with some
conversion I use the Fop driver
and my XML is dynamic.
WITH Transformer XALAN: 
StringWriter SstringWriter = new StringWriter();
/* this is the fo file */
StreamResult SstreamResult = new StreamResult(SstringWriter);

transformer.transform(SstreamSourceXML, SstreamResult)

/* convert the fo file in a right format for driver
ByteArrayOutputStream outPDF = new ByteArrayOutputStream();
SResult = SstringWriter.toString(); 
ByteArrayInputStream str = new ByteArrayInputStream(SResult.getBytes());
 
Driver driver = new Driver(new InputSource(str), outPDF);


Is this performance? I think yes!!

Bye
 

Amit wrote:
[EMAIL PROTECTED]"> Looking at
your code I am guessing that you wrote the fo file out to the filesystem
and then used the driver to convert it to PDF...how is performance on that? 
  
Instead of writing the file out to the file system did you try converting 
into some sorta stream and use the driver?? 
  thanks for your help 
Amit 
  Semprini Davide wrote: 
  Hi, 
I have had the same problem 
Nobody give me a response! 
This code in FOP Home page don't work (for me!) ! 
Driver driver = new Driver(); driver.setRenderer(Driver.RENDER_PDF); InputHandler inputHandler = new XSLTInputHandler(xmlFile, xslFile); XMLReader parser = inputHandler.getParser(); driver.setOutputStream(new FileOutputStream(outFile)); driver.render(parser, inputHandler.getInputSource());

I have solved the problem using 2 phase: 
1) generate the transformation using XSLTrasform, Xalan1Transform
etc... (you can choose) 
code: 
XSLTransform traXSLT = new XSLTransform(); 
traXSLT.transform(urlXML, urlXSL, urlFoFile); 
You can choose 4 transform type (see the api documentation) 
2) Apply the result at the driver 
FileInputStream file = new FileInputStream(urlFoFile); 
 response.setContentType("application/pdf"); 
 Driver driver = new Driver(new InputSource(file), out); 
 driver.setRenderer(Driver.RENDER_PDF); 
 driver.run(); 
 byte[] content = out.toByteArray(); 
 response.setContentLength(content.length); 
 response.getOutputStream().write(content); 
 response.getOutputStream().flush(); 
THIS CODE WORK FINE!!! 
Bye 
 
 
Amit wrote: 
[EMAIL PROTECTED]">
  I am trying to generate PDFs using FOP-0.20.1. The input files are xmland xsl filesI am using JRun3.0 with java1.2.2Here is the error I getWARNING: Unknown formatting object ^rootAnybody any ideas?-To unsubscribe, e-mail: [EMAIL PROTECTED]For additional commands, email: [EMAIL PROTECTED]
  
  
  
  
  
  


RE: FOP WARNING

2001-09-24 Thread Shkuro, Yuri

Two problem with this approach.  First, you are using a lot of memory to
store
intermediate XML result in a string buffer.  Second, you have to parse that
XML
again (FOP will do it for you, but it takes time).  A better solution, as I
already
said before, is to register FOP as a receiver of SAX events fired by XALAN
on the first transformation - this was you eliminate both problems and do
all
your work in one pass.  Just create a Transformer from the stylesheet and do

 // 3. Create FOP driver and set rendering mode and output stream
 org.apache.fop.apps.Driver driver = new org.apache.fop.apps.Driver();
 driver.setRenderer(driver.RENDER_PDF);
 driver.setOutputStream( whatever you writing to );

 // 4. Create SAXResult based on FOP Driver content handler which 
 // will accept SAX events and build FOP tree
 javax.xml.transform.sax.SAXResult saxResult =
   new javax.xml.transform.sax.SAXResult( driver.getContentHandler() );

 // 5. Use the Transformer to transform an XML Source and send the output 
 // to a Result object.
 //Implicitely it will create the FOP tree by firing SAX events
 transformer.transform( whatever XML source you have, saxResult );


YS
-Original Message-
From: Semprini Davide [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 24, 2001 9:42 AM
To: [EMAIL PROTECTED]
Subject: Re: FOP WARNING


Okay,

The example that I give is only to explain
that you can perform the PDF in two distinc phase
1) perform a trasformation 
2) use driver

You can use the tranform method 
with input like Dynamic xml (Dom Document) or urlXML  
and getting out a fo (Dom Document) or Writer object
YOU HAVE A LOT OF TRANSFORM TO USE!!
YOU HAVE TO SEE THE APIDOC FOR THE
COMPLETE DOCUMENTATION

For example in my project I use
xalan transform and with some
conversion I use the Fop driver
and my XML is dynamic.
WITH Transformer XALAN: 
StringWriter SstringWriter = new StringWriter();
/* this is the fo file */
 StreamResult SstreamResult = new StreamResult(SstringWriter);

transformer.transform(SstreamSourceXML, SstreamResult)

/* convert the fo file in a right format for driver
 ByteArrayOutputStream outPDF = new ByteArrayOutputStream();
 SResult = SstringWriter.toString();   
 ByteArrayInputStream str = new ByteArrayInputStream(SResult.getBytes());

 Driver driver = new Driver(new InputSource(str), outPDF);


Is this performance? I think yes!!

Bye
  

Amit wrote:

Looking at your code I am guessing that you wrote the fo file out to the
filesystem and then used the driver to convert it to PDF...how is
performance on that? 
Instead of writing the file out to the file system did you try converting
into some sorta stream and use the driver?? 
thanks for your help 
Amit 
Semprini Davide wrote: 
Hi, 
I have had the same problem 
Nobody give me a response! 
This code in FOP Home page don't work (for me!) ! 
Driver driver = new Driver();  driver.setRenderer(Driver.RENDER_PDF);
InputHandler inputHandler = new XSLTInputHandler(xmlFile, xslFile);
XMLReader parser = inputHandler.getParser();  driver.setOutputStream(new
FileOutputStream(outFile));  driver.render(parser,
inputHandler.getInputSource());

I have solved the problem using 2 phase: 
1) generate the transformation using XSLTrasform, Xalan1Transform etc...
(you can choose) 
code: 
XSLTransform traXSLT = new XSLTransform(); 
traXSLT.transform(urlXML, urlXSL, urlFoFile); 
You can choose 4 transform type (see the api documentation) 
2) Apply the result at the driver 
FileInputStream file = new FileInputStream(urlFoFile); 
response.setContentType(application/pdf); 
Driver driver = new Driver(new InputSource(file), out); 
driver.setRenderer(Driver.RENDER_PDF); 
driver.run(); 
byte[] content = out.toByteArray(); 
response.setContentLength(content.length); 
response.getOutputStream().write(content); 
response.getOutputStream().flush(); 
THIS CODE WORK FINE!!! 
Bye 
  
  
Amit wrote: 
I am trying to generate PDFs using FOP-0.20.1. The input files are xmland
xsl filesI am using JRun3.0 with java1.2.2Here is the error I getWARNING:
Unknown formatting object ^rootAnybody any
ideas?-T
o unsubscribe, e-mail: [EMAIL PROTECTED] additional
commands, email: [EMAIL PROTECTED]

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




Re: FOP WARNING

2001-09-24 Thread Amit


I am trying this piece of code and it can't find the xml and xsl files...
Anybody see anything that I am doing wrong?

public void makePDF(String xmlFile, String xslFile,

HttpServletResponse response) throws ServletException {

 java.io.Reader reader;
 Writer writer = new StringWriter();
 try {


ByteArrayOutputStream out = new ByteArrayOutputStream();
 XSLTransform.transform(xmlFile,

xslFile, writer);
 reader = new StringReader(writer.toString());

 response.setContentType("application/pdf");
 Driver driver = new Driver(new InputSource(reader),
out);
 driver.setRenderer(Driver.RENDER_PDF);
 driver.run();

byte[] content = out.toByteArray();

response.setContentLength(content.length);

response.getOutputStream().write(content);

response.getOutputStream().flush();
 } catch (Exception ex) {

throw new ServletException(ex);
 }

 }

Any help is greatly appreciated




Semprini Davide wrote:
Okay,
The example that I give is only to explain
that you can perform the PDF in two distinc phase
1) perform a trasformation
2) use driver
You can use the "tranform method"
with input like Dynamic xml (Dom Document) or urlXML
and getting out a fo (Dom Document) or Writer object
YOU HAVE A LOT OF TRANSFORM TO USE!!
YOU HAVE TO SEE THE APIDOC FOR THE
COMPLETE DOCUMENTATION
For example in my project I use
xalan transform and with some
conversion I use the Fop driver
and my XML is dynamic.
WITH Transformer XALAN:
StringWriter SstringWriter = new StringWriter();
/* this is the fo file */
StreamResult SstreamResult = new StreamResult(SstringWriter);
transformer.transform(SstreamSourceXML, SstreamResult)
/* convert the fo file in a right format for driver
ByteArrayOutputStream outPDF = new ByteArrayOutputStream();
SResult = SstringWriter.toString();
ByteArrayInputStream str = new ByteArrayInputStream(SResult.getBytes());
Driver driver = new Driver(new InputSource(str), outPDF);

Is this performance? I think yes!!
Bye

Amit wrote:
[EMAIL PROTECTED]">Looking at
your code I am guessing that you wrote the fo file out to the filesystem
and then used the driver to convert it to PDF...how is performance on that?
Instead of writing the file out to the file system did you try converting
into some sorta stream and use the driver??
thanks for your help
Amit
Semprini Davide wrote:
Hi,
I have had the same problem
Nobody give me a response!
This code in FOP Home page don't work (for me!) !
Driver driver = new Driver();
 driver.setRenderer(Driver.RENDER_PDF);
 InputHandler inputHandler = new XSLTInputHandler(xmlFile, xslFile);
 XMLReader parser = inputHandler.getParser();
 driver.setOutputStream(new FileOutputStream(outFile));
 driver.render(parser, inputHandler.getInputSource());

I have solved the problem using 2 phase:
1) generate the transformation using XSLTrasform, Xalan1Transform etc...
(you can choose)
code:
XSLTransform traXSLT = new XSLTransform();
traXSLT.transform(urlXML, urlXSL, urlFoFile);
You can choose 4 transform type (see the api documentation)
2) Apply the result at the driver
FileInputStream file = new FileInputStream(urlFoFile);
 response.setContentType("application/pdf");
 Driver driver = new Driver(new InputSource(file),
out);
 driver.setRenderer(Driver.RENDER_PDF);
 driver.run();
 byte[] content = out.toByteArray();
 response.setContentLength(content.length);
 response.getOutputStream().write(content);
 response.getOutputStream().flush();
THIS CODE WORK FINE!!!
Bye


Amit wrote:
[EMAIL PROTECTED]">
I am trying to generate PDFs using FOP-0.20.1. The input files are xml
and xsl files
I am using JRun3.0 with java1.2.2

Here is the error I get

WARNING: Unknown formatting object ^root

Anybody any ideas?




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