Project project = task.getProject();
TempFile tempFileTask = new TempFile();
tempFileTask.bindToOwner(task);
XSLTProcess xsltTask = new XSLTProcess();
xsltTask.bindToOwner(task);
xsltTask.setXslResource(getStylesheet());
// acrobatic cast.
xsltTask.setIn(((XMLResultAggregator) task).getDestinationFile());
File outputFile = null;
if (format.equals(FRAMES)) {
String tempFileProperty = getClass().getName() + String.valueOf(counter++);
File tmp = FILE_UTILS.resolveFile(project.getBaseDir(),
project.getProperty("java.io.tmpdir"));
tempFileTask.setDestDir(tmp);
tempFileTask.setProperty(tempFileProperty);
tempFileTask.execute();
outputFile = new File(project.getProperty(tempFileProperty));
} else {
outputFile = new File(toDir, "junit-noframes.html");
}
xsltTask.setOut(outputFile);
for (Iterator i = params.iterator(); i.hasNext();) {
XSLTProcess.Param param = (XSLTProcess.Param) i.next();
XSLTProcess.Param newParam = xsltTask.createParam();
newParam.setProject(task.getProject());
newParam.setName(param.getName());
newParam.setExpression(param.getExpression());
}
XSLTProcess.Param paramx = xsltTask.createParam();
paramx.setProject(task.getProject());
paramx.setName("output.dir");
paramx.setExpression(toDir.getAbsolutePath());
final long t0 = System.currentTimeMillis();
try {
xsltTask.execute();
} catch (Exception e) {
throw new BuildException("Errors while applying transformations: "
+ e.getMessage(), e);
}
final long dt = System.currentTimeMillis() - t0;