Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change Apache FOP Xalan XSLT Processor?

I am using Apache FOP 1.1.I want to change current apache Xalan XSLT processor to other for supporting XSLT 2.0. Currently it is not supporting XSLT 2.0. Please help me how to solve this problem. thank you.

like image 642
Oomph Fortuity Avatar asked Oct 15 '13 10:10

Oomph Fortuity


People also ask

What is Apache FOP used for?

Apache™ FOP (Formatting Objects Processor) is a print formatter driven by XSL formatting objects (XSL-FO) and an output independent formatter. It is a Java application that reads a formatting object (FO) tree and renders the resulting pages to a specified output.

What is FOP factory?

FOP will be configured with a default user agent instance. Use this factory method if your output type requires an output stream. MIME types are used to select the output format (ex. "application/pdf" for PDF). You can use the constants defined in MimeConstants .


2 Answers

I got my Answer. TransformerFactory has a plug-ability layer. JAXP provides a common Java interface that allows flexibilty to add various implementations of the supported standards XSLT processors.

TransformerFactory tFactory = TransformerFactory.newInstance();

This had look-up procedure to locate XSLT processors.AS we does not defined any,it will take available or default.

Now, I am adding SAXON XSLT processor . I have added it's .jar file in my project and just added

TransformerFactory tFactory = TransformerFactory.newInstance("net.sf.saxon.TransformerFactoryImpl",null); 

That's it. now it will use Saxon XSLT processor

like image 85
Oomph Fortuity Avatar answered Oct 10 '22 00:10

Oomph Fortuity


Another more flexible way is to start your application with a VM parameter like this -Djavax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactoryImpl which determines which Factory implementation to create (i.e. default XSLT processor).

This way, you don't have to change a single line of your code itself.

This is fine, if you embed FOP in your code (as you apparently did). If you want to run FOP as standalone distribution from command line, however, you can

  1. copy the required jar files with the XSLT processor (like e.g. Saxon.jar) to the lib directory of your distribution ($LOCAL_FOP_HOME/lib on Linux, %LOCAL_FOP_HOME%lib on Windows)

  2. and add the paramater to the start script (fop on Linux, fop.bat on Windows) at the line where org.apache.fop.cli.Main is called.

like image 25
Würgspaß Avatar answered Oct 10 '22 01:10

Würgspaß