Ming Yu wrote:
Hi,

I'm new to xslfo but I have been using xslt for a while. My question is, what 
is the best practice to output xml to pdf? As far as I understand, those are 
the step involved:

1. xml -> xslfo through xslt
2. xslfo -> pdf through FOP

But when writing xsl for step 1, I have to put all the fo coding inside xsl for 
the formatting. It seems to be very distracting.

If I know what data I want from the xml file and what design I want for the pdf 
output, is it possible to build the fo file first and add the xsl piece later 
on? I saw that xmlspy provides a tool to generate xsl:fo file from a design. Is 
this a good tool to use?

The first step is *usually* done through xslt, but that's not mandatory. You have to obtain an xslfo file from the original XML in any possible way. Now, the problem with xslt is that it mixes the processing code with the output in a not-too-clear way, which is a bit confusing if you don't have a good understanding of both languages.

You could take another approach, such as using an imperative programming language (like Java or C++ or Python) with an XML library, or a templating language (like Velocity, JSP or PHP), which allows you to actually write the skeleton of the resulting xslfo, with tiny blocks of processing code where the data from the XML must be inserted. The latter approach is closer to your idea of writing the xslfo first. You could write an example static xslfo file, then replace pieces of text with XML processing instructions.

Whatever approach you take, the process will still be valid, so feel free to choose the one you are more familiar with.

--
Sergiu Dumitriu
http://purl.org/net/sergiu/

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

Reply via email to