Convert XML to FO with FOP

Q

How to convert my data in XML to XSL-FO format with FOP? I have the XSLT file to define my data should be formatted.

✍: FYIcenter.com

A

If your data stored in XML format and you have an XSLT file that defines how data should be formatted, you can use the XSLT process provided in FOP to convert the XML file to an XSL-FO file as shown below:

\fyicenter>cd \local\fop-2.2\fop

\local\fop-2.2\fop>java -cp .\lib\xalan-2.7.2.jar;.\lib\serializer-2.7.2.jar 
   org.apache.xalan.xslt.Process 
   -IN examples\embedding\xml\xml\projectteam.xml 
   -XSL examples\embedding\xml\xslt\projectteam2fo.xsl 
   -OUT \temp\projectteam.fo   

\local\fop-2.2\fop>dir \temp\projectteam.fo
   2,176 projectteam.fo

The same example is provided in FOP 2.2, 2.1, and 2.0. But you need to change dependent JAR file versions accordingly.

 

Managing Fonts in FOP PDF Output

Call FOP with Debug Logging

FOP Commands and Examples

⇑⇑ FAQ for FOP (Formatting Object Processor)

2016-07-05, 1063👍, 0💬