Last active
October 1, 2016 20:50
-
-
Save BDF/019b770faa4eb5ff2505 to your computer and use it in GitHub Desktop.
Figuring out why saxon does not find license file in a Spring MVC application.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import net.sf.saxon.lib.FeatureKeys; | |
import net.sf.saxon.s9api.Processor; | |
import net.sf.saxon.s9api.SaxonApiException; | |
import net.sf.saxon.s9api.XsltCompiler; | |
import net.sf.saxon.s9api.XsltExecutable; | |
import org.springframework.stereotype.Service; | |
import javax.xml.transform.stream.StreamSource; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.net.URL; | |
import java.net.URLConnection; | |
/** | |
* Created by bforeste on 2/2/16. | |
* | |
* @author bforeste | |
*/ | |
@Service | |
public class XsltServiceSaxonImpl { | |
private final Processor proc; | |
public XsltServiceSaxonImpl() { | |
proc = new Processor(true); | |
} | |
public XsltExecutable compileXslt(StreamSource streamSource) throws SaxonApiException { | |
XsltCompiler xsltCompiler = proc.newXsltCompiler(); | |
XsltExecutable xsltExe = xsltCompiler.compile(streamSource); | |
return xsltExe; | |
} | |
// URL is the most generic way to handle our path to our XSLT resource. | |
// Current expected | |
public XsltExecutable compileXslt(URL urlToXslt) throws IOException, SaxonApiException { | |
XsltExecutable xsltExecutable; | |
URLConnection conn = urlToXslt.openConnection(); | |
InputStream fis = conn.getInputStream(); | |
StreamSource streamSource = new StreamSource(fis); | |
return compileXslt(streamSource); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment