简体   繁体   English

如何更改 Apache FOP Xalan XSLT 处理器?

[英]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.我正在使用 Apache FOP 1.1。我想将当前的 apache Xalan XSLT 处理器更改为其他以支持 XSLT 2.0。 Currently it is not supporting XSLT 2.0.目前它不支持 XSLT 2.0。 Please help me how to solve this problem.请帮助我如何解决这个问题。 thank you.谢谢。

I got my Answer.我得到了我的答案。 TransformerFactory has a plug-ability layer. TransformerFactory 具有可插入性层。 JAXP provides a common Java interface that allows flexibilty to add various implementations of the supported standards XSLT processors. JAXP 提供了一个通用的 Java 接口,允许灵活地添加支持的标准 XSLT 处理器的各种实现。

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.这有查找过程来定位 XSLT 处理器。因为我们没有定义任何,它将采用可用或默认值。

Now, I am adding SAXON XSLT processor .现在,我正在添加 SAXON XSLT 处理器。 I have added it's .jar file in my project and just added我已经在我的项目中添加了它的.jar 文件并刚刚添加

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

That's it.就是这样。 now it will use Saxon XSLT processor现在它将使用 Saxon XSLT 处理器

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 (ie default XSLT processor).另一种更灵活的方法是使用这样的 VM 参数启动应用程序-Djavax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactoryImpl确定要创建的工厂实现(即默认 XSLT 处理器)。

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).这很好,如果您在代码中嵌入 FOP(正如您显然所做的那样)。 If you want to run FOP as standalone distribution from command line, however, you can但是,如果您想从命令行将FOP 作为独立发行版运行,您可以

  1. copy the required jar files with the XSLT processor (like eg Saxon.jar) to the lib directory of your distribution ( $LOCAL_FOP_HOME/lib on Linux, %LOCAL_FOP_HOME%lib on Windows)使用 XSLT 处理器(例如 Saxon.jar)将所需的 jar 文件复制到您的发行版的lib目录(Linux 上$LOCAL_FOP_HOME/lib ,Windows 上为%LOCAL_FOP_HOME%lib

  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.并将参数添加到启动脚本(Linux 上的fop ,Windows 上的fop.bat )中调用org.apache.fop.cli.Main的那一行。

或者只是

TransformerFactory factory = new net.sf.saxon.TransformerFactoryImpl();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM