String xslt = getXslStringFromFile(filename, cl);
return newTransformer(systemId, xslt, uriResolver, map);
}
private byte[] doXSLTransformation(String filename, String secondChoice, String thirdChoice, byte[] in, ClassLoader cl) throws Exception {
Transformer transformer = getTransformerAlsoFromCache(filename, secondChoice, thirdChoice, cl);
if (transformer == null) {
log.warning("Transformer for file '" + filename + "' not found (where second choice was '" + secondChoice + "' and third choice was '" + thirdChoice + "', will return it without modification");
return in;
}
else {
StreamSource xmlStreamSource = new StreamSource(new ByteArrayInputStream(in));
ByteArrayOutputStream baos = new ByteArrayOutputStream(in.length);
StreamResult resultStream = new StreamResult(baos);
transformer.transform(xmlStreamSource, resultStream);
return baos.toByteArray();
}
}