I use Xalan in my application, but you need to use Saxon with a reference implementation to create test output for comparison. I want to use them during unit tests. However, as soon as I add the Saxon dependency to the .pom project, the application seems to use Saxon for all xslt and XPath operations during the tests:
<dependency> <groupId>net.sf.saxon</groupId> <artifactId>Saxon-HE</artifactId> <version>9.4</version> <scope>test</scope> </dependency>
This causes the main application to crash when generating output due to different XPath behavior. When starting the main application outside the scope of the scan, it works.
How to run the main application using Xalan, but tests using Saxon during tests?
I tried setting the following property before running the Xalan and Saxon parts:
System.setProperty("javax.xml.transform.TransformerFactory", "org.apache.xalan.processor.TransformerFactoryImpl "); System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl");
I also tried putting parts of Xalan and Saxon in different projects, and I also tried using them as from a third project, with the same result.
Danik source share