I've written a java application that utilizes JAXB for XSL transforms. I've included the saxon9.jar in my classpath so that I can use XSLT 2.0 rather than XSLT 1.0 on the command line.
我编写了一个java应用程序,它利用JAXB进行XSL转换。我包括saxon9。在我的类路径中jar,这样我就可以在命令行中使用XSLT 2.0而不是XSLT 1.0。
java -classpath ./lib/saxon9.jar:./ -jar myApp.jar
I've included code in my XSL to report the XSLT used.
我在XSL中包含了报告所用XSLT的代码。
<xsl:comment><xsl:text >
</xsl:text>XSLT Version: <xsl:value-of select="system-property('xsl:version')" /> <xsl:text >
</xsl:text>XSLT Vendor: <xsl:value-of select="system-property('xsl:vendor')" /> <xsl:text >
</xsl:text>XSLT Vendor URL: <xsl:value-of select="system-property('xsl:vendor-url')" /> <xsl:text >
</xsl:text></xsl:comment>
It reports.
它报告。
XSLT Version: 1.0
XSLT Vendor: Apache Software Foundation (Xalan XSLTC)
XSLT Vendor URL: http://xml.apache.org/xalan-j
This is the default implementation that is part of the JVM.
这是JVM的默认实现。
How do I get it to use the Saxon that I specified?
如何让它使用我指定的Saxon ?
Follow up:
跟进:
So none of these methods worked (except placing the saxon jar in the endorsed directory), but they all should have worked. It seems the combination of my using the "-jar myApp.jar" and wanting an alternative XSLT implementation were incompatible. In other words...
因此,这些方法都不起作用(除了将saxon jar放到已认可的目录中),但它们都应该起作用。似乎是我使用的“-jar myApp”的组合。jar和想要一个替代的XSLT实现是不兼容的。换句话说……
java -Djavax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactoryImpl -classpath ./lib/saxon9.jar:./ -jar myApp.jar
java -Djavax.xml.transform.TransformerFactory = net.sf.saxon。/ lib / saxon9.jar:TransformerFactoryImpl类路径。/ jar myApp.jar
...does not work, but this does...
…不起作用,但这确实……
java -Djavax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactoryImpl -classpath ./lib/saxon9.jar:./myApp.jar org.dacracot.myApp
java -Djavax.xml.transform.TransformerFactory = net.sf.saxon。TransformerFactoryImpl类路径/ lib / saxon9.jar:。/ myApp。jar org.dacracot.myApp
...interestingly, I don't even have to specify the factory and I get the saxon version...
有趣的是,我甚至不需要指定工厂,我得到了saxon版本……
java -classpath ./lib/saxon9.jar:./myApp.jar org.dacracot.myApp
java类路径。/ lib / saxon9.jar:/ myApp。jar org.dacracot.myApp
5 个解决方案
#1
2
Check out the javadoc for TransformerFactory.newInstance() for all the possible ways to configure the factory.
检查javadoc中的TransformerFactory.newInstance(),了解配置工厂的所有可能方法。
- System Property
- 系统属性
- lib/jaxp.properties
- lib / jaxp.properties
- Services config file (may be in the saxon JAR, /META-INF/services/javax.xml.transform.TransformerFactory)
- 服务配置文件(可能在saxon JAR、/META-INF/ Services /javax.xml.transform.TransformerFactory中)
#2
2
Have you tried placing your jar in the endorsed directory?
您是否尝试过将您的jar放到已背书的目录中?
If you don't want the effect to be global, use the following option:
如果您不希望影响全局,请使用以下选项:
-Djava.endorsed.dirs=my_dir
in the command line.
在命令行。
#3
2
The last example you posted(w/o -Djavax...) works because the META-INF/services directory contains a file named
您发布的最后一个示例(w/o -Djavax…)可以工作,因为META-INF/services目录包含一个名为的文件
java.xml.transform.TransformerFactory
java.xml.transform.TransformerFactory
with the content
与内容
net.sf.saxon.TransformerFactoryImpl
net.sf.saxon.TransformerFactoryImpl
The reason using
使用的原因
java -cp lib/saxon9.jar;myjar.jar
works and
工作和
java -cp lib/saxon9.jar -jar myjar.jar
doesn't is that using the -jar option tells java(w).exe to ignore the rest of the command line and pull everything (classpath included) from the jar's manifest file. If you put saxon9.jar in your jar manifest's classpath it should work.
不是说使用-jar选项会告诉java(w)。exe忽略命令行其余部分,并从jar的清单文件中提取所有内容(包括类路径)。如果你把saxon9。jar在jar清单的类路径中,它应该可以工作。
Manifest-Version: 1.0
Main-Class: net.my.MainClass
Class-Path: lib/saxon9.jar
#4
1
This system property should set the replacement TransformerFactory:
本系统属性设置更换变压器:
java -Djavax.xml.transform.TransformerFactory=com.foobar.AcmeTransformer MyApp
I believe the factory class you want is net.sf.saxon.TransformerFactoryImpl
我相信你想要的工厂类是net. sf.萨克森. transformerfactoryimpl
#5
0
How about
如何
java -Xbootclasspath:lib/saxon9.jar -classpath . -jar myApp.jar
#1
2
Check out the javadoc for TransformerFactory.newInstance() for all the possible ways to configure the factory.
检查javadoc中的TransformerFactory.newInstance(),了解配置工厂的所有可能方法。
- System Property
- 系统属性
- lib/jaxp.properties
- lib / jaxp.properties
- Services config file (may be in the saxon JAR, /META-INF/services/javax.xml.transform.TransformerFactory)
- 服务配置文件(可能在saxon JAR、/META-INF/ Services /javax.xml.transform.TransformerFactory中)
#2
2
Have you tried placing your jar in the endorsed directory?
您是否尝试过将您的jar放到已背书的目录中?
If you don't want the effect to be global, use the following option:
如果您不希望影响全局,请使用以下选项:
-Djava.endorsed.dirs=my_dir
in the command line.
在命令行。
#3
2
The last example you posted(w/o -Djavax...) works because the META-INF/services directory contains a file named
您发布的最后一个示例(w/o -Djavax…)可以工作,因为META-INF/services目录包含一个名为的文件
java.xml.transform.TransformerFactory
java.xml.transform.TransformerFactory
with the content
与内容
net.sf.saxon.TransformerFactoryImpl
net.sf.saxon.TransformerFactoryImpl
The reason using
使用的原因
java -cp lib/saxon9.jar;myjar.jar
works and
工作和
java -cp lib/saxon9.jar -jar myjar.jar
doesn't is that using the -jar option tells java(w).exe to ignore the rest of the command line and pull everything (classpath included) from the jar's manifest file. If you put saxon9.jar in your jar manifest's classpath it should work.
不是说使用-jar选项会告诉java(w)。exe忽略命令行其余部分,并从jar的清单文件中提取所有内容(包括类路径)。如果你把saxon9。jar在jar清单的类路径中,它应该可以工作。
Manifest-Version: 1.0
Main-Class: net.my.MainClass
Class-Path: lib/saxon9.jar
#4
1
This system property should set the replacement TransformerFactory:
本系统属性设置更换变压器:
java -Djavax.xml.transform.TransformerFactory=com.foobar.AcmeTransformer MyApp
I believe the factory class you want is net.sf.saxon.TransformerFactoryImpl
我相信你想要的工厂类是net. sf.萨克森. transformerfactoryimpl
#5
0
How about
如何
java -Xbootclasspath:lib/saxon9.jar -classpath . -jar myApp.jar