简体   繁体   中英

Saxon - how to call from Java with JBOSS 4.2.3

My current transformer is xalan that came with Jboss and is in the path 'C:\\apps\\jboss-4.2.3.GA\\lib\\endorsed\\xalan.jar"

My batch file that starts up Jboss and sets all of the variables for it has a section for 'Use Compiling XSLT Processor (XSLTC)'. It has the current value of:

set JAVA_OPTS=%JAVA_OPTS% -Djavax.xml.transform.TransformerFactory=com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl

If I put my copy of 'saxon9he.jar' into the 'C:\\apps\\jboss-4.2.3.GA\\lib\\endorsed\\' folder, how would I change the line above in my batch file to call the 'saxon9he.jar' file?

I'm guessing that its being called now by an API?

You can try changing the value of the TransformerFactory property to

net.sf.saxon.TransformerFactoryImpl

There's a risk that this will redirect all JAXP operations to use Saxon instead of Xalan, and in a big system like JBoss there's a significant possibility that there will be some application components that assume Xalan will be loaded and fail if they get something else. So a safer approach is to change only the code that you explicitly want to use Saxon, which you can do by replacing the standard JAXP call

TransformerFactory factory = TransformerFactory.newInstance();

by

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

Apart from being more robust in ensuring you get the processor you expect, it's also a lot faster to instantiate the class directly rather than using the JAXP classpath search.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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