xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From flattr.toms...@online.ms
Subject Re: Default XSL Stylesheet for PDF?
Date Tue, 25 Oct 2011 08:34:25 GMT
Hi Jeffrey,

p, li { white-space: pre-wrap; }
On Tuesday 25 October 2011 Jeffrey Walton wrote:
> [...]
> > If you were curious the -xml input is used in conjunction with an XSLT
> > (thus the -xsl parameter) to transform said XML file to FO. There is
> > no "default" PDF stylesheet, this mechanism is merely a helper since a
> > lot of users create FO using a transform.
>
> OK. xalan also complains about a style sheet. These style sheets seem
> important.
 
They are not important, they are essential! :-)
 
 
> $ xalan -in book.xml
> XSLT Error: Failed to process stylesheet. (line -1, column -1.)
 
You miss a -xsl option. If you do not know how to run xalan, use the -h or --help option to
display an overview. There it should give you an idea what options xalan needs.
 
 
> XSLException Type is: XSLTProcessorException
> Message is: Failed to process stylesheet. (Unknown URI, line -1, column -1)
 
You miss one point: Xalan complains correctly so as you forgot to add a XSLT stylesheet. I'm
not that familiar with Xalan, so I usually use xsltproc. Here is an example:
 
$ DB=/usr/share/xml/docbook/stylesheet/nwalsh/current/
$ xsltproc --output book.fo $DB/fo/docbook.xsl book.xml
 
The basic principle is the same regardless of the XSLT processor.
 
Let me explain these two lines:
The first line is just a convenience variable. You need to change that path to point to your
DocBook XSL stylesheets. Search for a package with docbook-xsl or the like. Just add the _path_.
 
The second line is the transformation. It needs the XSLT stylesheet which is $DB/fo/docbook.xsl
as one input and your DocBook XML document book.xml as another input. The result of the transformation
is saved in book.fo.
 
 
> Out of curiosity, how do you create a PDF from a XML (DocBook) book. I
> haven't had any luck with docbook2pdf, xsltproc, xalan, fop, etc.
 
You miss some options, probably also some basics. See next paragraph.
 
 
> I am amazed at how difficult the designers/architects have made this
> process.
 
I can assure you, the developers did NOT try it to make it difficult just to annoy users.
Actually it is really simple, you just need to understand some basic steps. Here are the steps
from DocBook XML to PDF:
 
 
1. Validate your DocBook XML file first
Do NOT skip this step! Use xmllint and run it like this:
$ xmllint --xinclude --postvalid --noout book.xml
If you encounter any problems, fix it. DO NOT processed further if you
encounter any errors. The other steps rely on a valid DocBook source.
 
2. Transform your DocBook XML file into FO
The FO file is an intermediate file which is read by your FO formatter.
I've already wrote about how to run xsltproc. See lines above.
 
3. Format the FO file
Now you take your FO file and feed it into the FO formatter:
$ fop book.fo book.pdf
 

These are three simple steps, each rely on the previous. If you have an invalid DocBook source,
it is useless to go further. Just fix your file(s). The tranformation from DocBook to FO is
usually without problems. When you try to format the intermediate FO file, that depends on
the formatter. Sometimes FOP is a bit picky. :)
 
Hope that helps.

p, li { white-space: pre-wrap; }
--
Gruß/Regards,
Thomas Schraitle

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Mime
View raw message