A little over a month ago I switched from running fop using a shell
script to using ant, as per Eric Vought's suggestion copied below.
Today I ran into a strange file-naming issue.
I am processing multiple files based on state and grade level. The
PDFs will eventually end up on a Web site. I asked the Web master how
she wanted the files named. She gave me this format (this would be
for Illinois grade 3 file):
il_rex_corr_3.pdf
I converted my xml to fo using <xsl:result-document> so as to output
fo files. So the above fo file was output as--
il_rex_corr_3.fo
I ran my ant process against the folder of grade 3 fo files with no
hitch. When I went to run the grade 4 files, I received this error:
$ /Applications/apache-ant-1.7.0/bin/ant
Buildfile: build.xml
make_pdf:
[fop] /Users/home/Active_Documents/00Standards_Based_Kits/
Correlation_Confabulators/G4Finalxml/fo_files/.fo -> /Users/home/
Active_Documents/00Standards_Based_Kits/Correlation_Confabulators/
G4Finalxml/pdf_files/.pdf
[fop] [Fatal Error] :-1:-1: Premature end of file.
[fop] Feb 22, 2008 10:56:05 AM org.apache.fop.cli.InputHandler
error
[fop] SEVERE: javax.xml.transform.TransformerException:
Premature end of file.
BUILD FAILED
/Users/home/Active_Documents/00Standards_Based_Kits/
Correlation_Confabulators/G4Finalxml/build.xml:25:
javax.xml.transform.TransformerException:
org.xml.sax.SAXParseException: Premature end of file.
There were two differences between the grade 3 and grade 4 runs.
a) they were launched from different directories, and
b) the file names were numbered differently: '4' in place of the
'3' (il_rex_corr_4.fo)
I finally got the ant/fop process to run by adding a '4' to the
"include" line in the build.xml:
old build:
<target name="make_pdf"
description="Generates multiple PDF files">
<fop format="application/pdf"
outdir="${build.dir}" messagelevel="debug">
<fileset dir="${source.dir}">
<include name="*.fo"/>
</fileset>
</fop>
</target>
New build:
<target name="make_pdf"
description="Generates multiple PDF files">
<fop format="application/pdf"
outdir="${build.dir}" messagelevel="debug">
<fileset dir="${source.dir}">
<include name="*4.fo"/>
</fileset>
</fop>
</target>
I wonder:
a) Is it not such a good idea to end a basefile name with a number?
b) Is there some sort of cache memory in either ant or fop that
refused to see the 4 in place of the 3?
??
Terry
On Jan 3, 2008, at 5:38 PM, Eric Vought wrote:
If you are doing that much formatting, you may really want to check
out using ant for your build process, especially if doing multiple
output formats. I use this on Mac OS X and have no problem with
background running or anything else. My rule for PDF formatting is
just:
<target name="pdf" depends="-fo" description="Produce the PDF">
<fop format="application/pdf" basedir="${formatdir}"
fofile="${formatdir}/${basename}.fo"
outfile="${formatdir}/${basename}.pdf"/>
</target>
It is easy to adapt this to use a glob rule to build a list of
files to format and I also have my process automatically validate
DocBook inputs, produce single file and chunked HTML, ODF, convert
graphics files from SVG as necessary, automatically check dates to
only format what is needed, zip the formatted files and graphics
for distribution, clean up the working directories, and even do
some dependency tracking on what versions of DocBook, the XSLT
stylesheets, fop and other libraries I am using for a particular
document so I don't have trouble when I check out an old one from
version control. I have a template build file I include for each
project and then customize. It took me a good bit of work to set up
the environment but has been very easy to maintain.
This is not a huge matter. More on the line of an annoyance. And I
may need to take this question to a java list rather than this
list. If so, just point me in the right direction.
At any rate, I have an XSLT stylesheet that produces 50+ separate
fo documents. I then run the shell script below to batch produce
the pdf documents:
#!/bin/sh
for foo in *.fo
do
state=`basename $foo .fo`
/Applications/fop-0.94/fop -fo $foo -pdf ../pdf_files/$state.pdf
done
When I run this script on my Mac (OS X 10.4.11, java version
"1.5.0_13" fop-0.94), org.apache.fop.cli.main takes control of the
desktop, stopping whatever it is I am doing for about 5 seconds. I
gain control again for about 5 seconds until fop pumps out another
pdf document. I basically have to step away from the computer for
the 8 minutes that the batch process takes. Adding & and wait to
the main line of the script does not seem to work:
/Applications/fop-0.94/fop -fo $foo -pdf ../pdf_files/$state.pdf &
wait
done
The first script above on Ubuntu linux runs in the background
without interrupting other running process.
Any simple solutions?
Terry Ofner
Sincerely,
Eric Vought
"Deserves Death? I daresay he does. Many who live deserve death.
Many who die deserve life. Can you give it to them, Frodo? Do not
be so quick to deal death in the name of justice. Even the very
wise cannot see all ends." -- Gandalf the Grey
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]