Apache FOP with Java with XSLT 2.0 ...?

I'm having trouble using some of the XSLT 2.0 features in native use of Apache FOP 1.0. In particular, I get an exception when using "current-group ()".

I see that FOP uses xalan 2.6, which throws an exception.

I tried to eliminate the transitive dependency of xalan 2.6 and replace it with 2.7.1, but that did not help. Is it possible to use Apache FOP with another XSLT processor that supports more than 2.0 functions?

+4
source share
2 answers

If you need 2.0 functions in XSLT, XPath ... try a different XSLT processor / engine other than JDK or Xalan, like Saxon . It has a free version and a commercial version if you want to be aware of the scheme. We use Apache-FOP to create PDF files from XML data and work great, and you get a new feature in version 2.0, such as date and number formatting. Just use saxon9.jar and specify the XSLT engine (saxon) used.

+1
source

If you run FOP as a standalone distribution from the command line, you can

  • copy the necessary jar files using the XSLT processor (e.g. saxon9he.jar ) into the lib directory of your FOP distribution.

  • and indicate the processor implementation that will be used by FOP by adding such a VM parameter -Djavax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactoryImpl (example for Saxon) to the top of the script ( fop on Linux, fop.bat on Windows) in the line where org.apache.fop.cli.Main is called.

If you embed FOP in your Java code , just run the application with this VM option (and make sure the necessary jar files are in your CLASSPATH ).

0
source

Source: https://habr.com/ru/post/1369654/


All Articles