in src/main/java/org/apache/easyant/tasks/PluginReport.java [270:340]
private void genStyled(File reportFile, File style, EasyAntReport easyantReport) throws IOException {
InputStream xsltStream = null;
try {
// create stream to stylesheet
xsltStream = new BufferedInputStream(new FileInputStream(style));
Source xsltSource = new StreamSource(xsltStream, JAXPUtils.getSystemId(style));
// create transformer
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(xsltSource);
// add the provided XSLT parameters
for (Param param : params) {
transformer.setParameter(param.getName(), param.getExpression());
}
ModuleRevisionId moduleRevisionId = easyantReport.getModuleDescriptor().getModuleRevisionId();
File outFile;
if (toFile != null) {
outFile = toFile;
} else {
outFile = new File(todir, getOutputPattern(moduleRevisionId, conf, xslext));
}
log("Processing " + reportFile + " to " + outFile);
// make sure the output directory exist
File outFileDir = outFile.getParentFile();
if (!outFileDir.exists()) {
if (!outFileDir.mkdirs()) {
throw new BuildException("Unable to create directory: " + outFileDir.getAbsolutePath());
}
}
InputStream inStream = null;
OutputStream outStream = null;
try {
inStream = new BufferedInputStream(new FileInputStream(reportFile));
outStream = new BufferedOutputStream(new FileOutputStream(outFile));
StreamResult res = new StreamResult(outStream);
Source src = new StreamSource(inStream, JAXPUtils.getSystemId(style));
transformer.transform(src, res);
} catch (TransformerException e) {
throw new BuildException(e);
} finally {
if (inStream != null) {
try {
inStream.close();
} catch (IOException e) {
// ignore
}
}
if (outStream != null) {
try {
outStream.close();
} catch (IOException e) {
// ignore
}
}
}
} catch (TransformerConfigurationException e) {
throw new BuildException(e);
} finally {
if (xsltStream != null) {
try {
xsltStream.close();
} catch (IOException e) {
// ignore
}
}
}
}