Skip to content
Snippets Groups Projects
Commit de2fe096 authored by srosse's avatar srosse
Browse files

OO-3967: try to use the XSLT transformer of the JDK (CXalan)

parent a6024d20
No related branches found
No related tags found
No related merge requests found
......@@ -37,6 +37,7 @@ import javax.xml.transform.Source;
import javax.xml.transform.Templates;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerFactoryConfigurationError;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamResult;
......@@ -182,7 +183,7 @@ public class LocalizedXSLTransformer {
log.error("Could not convert xsl to string!", e);
}
String replacedOutput = evaluateValue(xslAsString, vcContext);
TransformerFactory tfactory = TransformerFactory.newInstance();
TransformerFactory tfactory = newTransformerFactory();
XMLReader reader;
try {
reader = XMLReaderFactory.createXMLReader();
......@@ -195,6 +196,24 @@ public class LocalizedXSLTransformer {
throw new OLATRuntimeException("Could not initialize transformer (wrong config)!", e);
}
}
/**
* The method try to find the Xalan implementation of the JDK because the styelsheet
* was with this one develop and not the Saxon XSLT 2.0 or 3.0 engine which lead to
* some compatibility issue with special HTML entity (example: 129).
*
* @return Try to get the embedded Xalan implementation which is a pure XSLT 1.0 engine.
*/
private TransformerFactory newTransformerFactory() {
TransformerFactory tfactory = null;
try {
tfactory = TransformerFactory.newInstance("com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl", null);
} catch (TransformerFactoryConfigurationError e) {
log.error("", e);
tfactory = TransformerFactory.newInstance();
}
return tfactory;
}
/**
* Takes String with template and fills values from Translator in Context
......@@ -231,7 +250,7 @@ public class LocalizedXSLTransformer {
* @throws IOException
*/
private static String slurp(InputStream in) throws IOException {
StringBuffer out = new StringBuffer();
StringBuilder out = new StringBuilder();
byte[] b = new byte[4096];
for (int n; (n = in.read(b)) != -1;) {
out.append(new String(b, 0, n));
......
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