mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
9043 use Templates for compiled XSLT instead of Transformer - use Templates are thread-safe and NOT Transformer
(cherry picked from commit 1160341cb2
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
0ddc05bffb
commit
5596cc686d
@@ -15,7 +15,7 @@
|
||||
<properties>
|
||||
<!-- This is the path to the root [dspace-src] directory. -->
|
||||
<root.basedir>${basedir}/..</root.basedir>
|
||||
<xoai.version>3.3.0</xoai.version>
|
||||
<xoai.version>3.3.1-SNAPSHOT</xoai.version>
|
||||
<jtwig.version>5.87.0.RELEASE</jtwig.version>
|
||||
</properties>
|
||||
|
||||
|
@@ -12,7 +12,7 @@ import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.Templates;
|
||||
import javax.xml.transform.TransformerConfigurationException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
@@ -40,8 +40,7 @@ public class DSpaceResourceResolver implements ResourceResolver {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transformer getTransformer(String path) throws IOException,
|
||||
TransformerConfigurationException {
|
||||
public Templates getTemplates(String path) throws IOException, TransformerConfigurationException {
|
||||
// construct a Source that reads from an InputStream
|
||||
Source mySrc = new StreamSource(getResource(path));
|
||||
// specify a system ID (the path to the XSLT-file on the filesystem)
|
||||
@@ -49,6 +48,6 @@ public class DSpaceResourceResolver implements ResourceResolver {
|
||||
// XSLT-files (like <xsl:import href="utils.xsl"/>)
|
||||
String systemId = basePath + "/" + path;
|
||||
mySrc.setSystemId(systemId);
|
||||
return transformerFactory.newTransformer(mySrc);
|
||||
return transformerFactory.newTemplates(mySrc);
|
||||
}
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ public class PipelineTest {
|
||||
InputStream input = PipelineTest.class.getClassLoader().getResourceAsStream("item.xml");
|
||||
InputStream xslt = PipelineTest.class.getClassLoader().getResourceAsStream("oai_dc.xsl");
|
||||
String output = FileUtils.readAllText(new XSLPipeline(input, true)
|
||||
.apply(factory.newTransformer(new StreamSource(xslt)))
|
||||
.apply(factory.newTemplates(new StreamSource(xslt)))
|
||||
.getTransformed());
|
||||
|
||||
assertThat(output, oai_dc().withXPath("/oai_dc:dc/dc:title", equalTo("Teste")));
|
||||
|
Reference in New Issue
Block a user