Re: [xsl] Fw: pdf file using xsl

Subject: Re: [xsl] Fw: pdf file using xsl
From: njain@xxxxxxx
Date: Wed, 29 Mar 2006 11:48:55 -0500
James,
        Thanks you for the response.
        I already generated the small pdf report, which works very well. 
To me it looks like a memory issue, I haven't figured out as to what the 
exact size of the output which causes the application to break. I see the 
Windows Task Manager when the report is run and I observed that the memory 
usage increases dramatically, up to 409MB. Now to my understanding this is 
an issue with FOP, as I am supplying an FO object to it. So it doesn't 
have to use any XSLT, all it needs to do is transform the FO object to 
PDF. My XSL transformation takes only 1-2 minutes, for generating an 313MB 
FO object.

        I read in other websites that if heavy use of forward references 
and objects could result in more memory usage. I am using 4 tables, 2 
markers and a number of outline objects. Not sure if this could be an 
issue.

        I'll try to see if I could break the xml into smaller chunks and 
then get the output. Is it possible to generate different pdf files and 
then merge them using FOP.
---
Neeraj Jain
3M HIS, 
8 King Road, Rockleigh
NJ. 07647 USA
Direct - 201 750 5931
njain@xxxxxxx
neerajj@xxxxxxxxxxx



James Neff <jneff@xxxxxxxxxxxxxxxx> 
03/29/2006 11:37 AM

To
njain@xxxxxxx
cc

Subject
Re: [xsl] Fw: pdf file using xsl






I'm sorry, but I don't know much about FO itself.  I have had problems 
with lage data files and memory problems with regular XML and XSL 
processing.  I ended up having to break the whole process down into bite 
sized pieces.  I found out that the processor becomes less efficient the 
larger the source file is.  So I was able to break my process down into 4 
smaller pieces and then reassamble them later.  I don't know if thats an 
option for you or not.

Probably one of the FO gurus will respond and tell you the correct way to 
fix this.  Although 2.5 GB of memory isn't unheard of these days, throwing 
more horsepower at the problem shouldn't be the answer.  To me, more 
efficiency is the answer.  Saxon is a very efficient XSL processor so if 
its taking too long then chances are I'm doing something wrong.

I would start by verifying your process is valid (in at least some cases). 
 Take a small set of good data that will procude the PDF file you want and 
run that just to see if it works.  If that works, then increase the input 
data until you reproduce the error.  That probably means its a memory 
issue.  If Its a memory issue, you need to determine if its just the stack 
heap isn't set high enough or is there some kind of loop your triggering 
with some data.  If its the loop problem then its an application issue 
(not a technical issue with FO) and then you have to scrub the input data 
before allowing it into your process. 

I will have to deal with FO in the future though and something I need to 
add to my XML R'epertoire. 

Good luck, sorry I couldn't help you more.

--James


njain@xxxxxxx wrote: 
James,
        Thanks for the response.
        My report size could grow from 1MB to 1GB, it entirely depends on 
the user's selection. So if decides to get a big report, say 500 MB, I'll 
have to allocate 5*500=2.5GB of RAM. I was wondering if it's a possibility 

to stream the data instead of holding in memory.
        Not sure if the XML structure is complex, but I need to use 
xsl:for-each-group to process the xml. Apart from this, I broke the 
process as follows:
        1. Use xml and xsl to generate the FO object
        2. Use FOP to generate the pdf from FO object created in step-1.

        I am kind of okay with step-1, since it takes about 1-2 mins to 
process. But step 2 takes a long time, and doesn't give any result.
 
        Following is the code used to generate the pdf.
 
        Driver driver = new Driver();
        File outFile = new File("c:\\out.pdf");
                File inputFile = new File("c:\\in.pdf");        // This is 

the FO Object which is created using the XSLT-2.0 processor(Saxon8)
        OutputStream fopout = new FileOutputStream(outFile);
        driver.setOutputStream(fopout);
        driver.setRenderer(Driver.RENDER_PDF);
        driver.setInputSource(new InputSource(new 
FileInputStream(inputFile)));
        driver.run();
---
Neeraj Jain
3M HIS, 
8 King Road, Rockleigh
NJ. 07647 USA
Direct - 201 750 5931
njain@xxxxxxx
neerajj@xxxxxxxxxxx



James Neff <jneff@xxxxxxxxxxxxxxxx> 
03/29/2006 10:59 AM
Please respond to
xsl-list@xxxxxxxxxxxxxxxxxxxxxx


To
xsl-list@xxxxxxxxxxxxxxxxxxxxxx
cc

Subject
Re: [xsl] Fw: pdf file using xsl






Neeraj,

Just real quick, try increasing the memory size much more.  Depending on
your XML structure (and how your processing it), the processor can use
up to 10 times the input file size in memory to apply a stylesheet to it.

Try setting it to 5-10 times what you have already.

--James


njain@xxxxxxx wrote:

 
Hello,
I tried this message earlier but it bounced back. I am new to this
I am working on an application which requires me to generate a pdf file 
of up to 200MB size. I tried generating xml file and then apply xsl on it 
 

 
with the Apache FOP driver.

The result is "Out of Memory" error. I am not sure where the out of 
 
memory 
 
error is coming, in FOP code or in Saxon8(I am using Saxon processor and 
XSLT 2.0).

Could anyone please help me out and let me know what could be wrong.

PS: I have already tried to increase the JVM memory (-Xms218m -Xmx512m).

Regards.
Neeraj 

Current Thread