title: Using Xalan alongside Saxon
body: <p>I use Xalan in my application, but need to use Saxon with a reference implementation to generate test output to compare with. I want to use them both during unit tests.
  However, as soon as I add an dependency on Saxon in the project .pom, the application seems to use Saxon for all xslt and XPath operations during tests:</p>
  
  <pre><code>&lt;dependency&gt;
    &lt;groupId&gt;net.sf.saxon&lt;/groupId&gt;
    &lt;artifactId&gt;Saxon-HE&lt;/artifactId&gt;
    &lt;version&gt;9.4&lt;/version&gt;
    &lt;scope&gt;test&lt;/scope&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>This makes the main application fail when generating output due to a different XPath behaviour. When running the main application outside of test scope it works.</p>
  
  <p>How can I run the main application using Xalan, but the tests using Saxon, during tests?</p>
  
  <p>I have tried setting the following property before running the Xalan and Saxon parts:</p>
  
  <pre><code>System.setProperty("javax.xml.transform.TransformerFactory", "org.apache.xalan.processor.TransformerFactoryImpl ");
  System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl");
  </code></pre>
  
  <p>I have also tried to put the Xalan and Saxon parts in different projects, and I have also tried to use them both from a third project, with the same result.</p>