Skip to content
Snippets Groups Projects
Commit ab10a8b4 authored by Thorsten Vitt's avatar Thorsten Vitt
Browse files

Compile the XSLT stylesheet in the constructor

parent 6b27719e
No related branches found
No related tags found
No related merge requests found
......@@ -39,6 +39,20 @@ public class EPUB {
final Logger logger = Logger.getLogger("info.textgrid.services.aggregator");
private XsltExecutable teiToEpub;
private final Processor xsltProcessor;
public EPUB() {
xsltProcessor = new Processor(false);
final XsltCompiler xsltCompiler = xsltProcessor.newXsltCompiler();
try {
teiToEpub = xsltCompiler.compile(new StreamSource("/usr/share/xml/tei/stylesheet/epub/tei-to-epub.xsl"));
} catch (final SaxonApiException e) {
throw new IllegalStateException(e);
}
}
@GET
@Path(value="/{object}")
@Produces(value="application/epub+zip")
......@@ -70,11 +84,10 @@ public Response get(@PathParam("object") final URI uri) {
corpusSerializer.write(corpusOutput);
corpusOutput.close();
final Processor processor = new Processor(false);
final XsltCompiler xsltCompiler = processor.newXsltCompiler();
final XsltExecutable teiToEpub = xsltCompiler.compile(new StreamSource("/usr/share/xml/tei/stylesheet/epub/tei-to-epub.xsl"));
// Now, run the EPUB stylesheet
// TODO cache the saxon stuff
final XsltTransformer transformer = teiToEpub.load();
transformer.setDestination(processor.newSerializer(new File(workingDir, "output.xml")));
transformer.setDestination(xsltProcessor.newSerializer(new File(workingDir, "output.xml")));
transformer.setSource(new StreamSource(corpus));
transformer.transform();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment