/** * Add a nested <style> element. * @param rc the configured Resources object represented as <style>. * @since Ant 1.7 */ public void addConfiguredStyle(final Resources rc) { if (rc.size() != 1) { handleError( "The style element must be specified with exactly one nested resource."); } else { setXslResource(rc.iterator().next()); } }
/** * Set the reference to an optional classpath to the XSL processor * * @param r the id of the Ant path instance to act as the classpath * for loading the XSL processor */ public void setClasspathRef(final Reference r) { createClasspath().setRefid(r); }
private void gen(ResolutionCacheManager cache, String organisation, String module, String style, String ext) throws IOException { XSLTProcess xslt = new XSLTProcess(); xslt.setTaskName(getTaskName()); xslt.setProject(getProject()); xslt.init(); String resolveId = ResolveOptions.getDefaultResolveId(new ModuleId(organisation, module)); xslt.setIn(cache.getConfigurationResolveReportInCache(resolveId, "default")); xslt.setOut(new File(getTodir(), outputname + "." + ext)); xslt.setBasedir(cache.getResolutionCacheRoot()); xslt.setStyle(style); xslt.execute(); }
private XSLTProcess xsltTask() { XSLTProcess xsltTask = new XSLTProcess(); xsltTask.bindToOwner(task); xsltTask.setClasspath(classpath); xsltTask.setXslResource(getStylesheet()); xsltTask.setIn(((XMLResultAggregator) task).getDestinationFile()); return xsltTask; }
tempFileTask.bindToOwner(task); xsltTask.setXslResource(getStylesheet()); xsltTask.setIn(((XMLResultAggregator) task).getDestinationFile()); File outputFile; if (FRAMES.equals(format)) { outputFile = new File(toDir, "junit-noframes.html"); xsltTask.setOut(outputFile); XSLTProcess.Param paramx = xsltTask.createParam(); paramx.setProject(task.getProject()); paramx.setName("output.dir"); final long t0 = System.currentTimeMillis(); try { xsltTask.execute(); } catch (Exception e) { throw new BuildException("Errors while applying transformations: " + e.getMessage(), e);
void performXslt(XSLTProcess task, File outFile) { File inFile = new File(inXml); init(task); task.addConfiguredXMLCatalog(xmlCatalog); task.setIn(inFile); task.setOut(outFile); task.setForce(true); setXslResource(task); task.perform(); }
/** * Performs the XSLT transformation to generate the HTML report. * * @throws BuildException thrown if something goes wrong with the transformation. */ @Override public void transform() throws BuildException { checkOptions(); TempFile tempFileTask = tempFileTask(); XSLTProcess xsltTask = xsltTask(); File outputFile = outputFile(tempFileTask); xsltTask.setOut(outputFile); createNewParams(xsltTask); createOutputDirParam(xsltTask); long startingTime = System.currentTimeMillis(); try { xsltTask.execute(); } catch (Exception e) { throw new BuildException(concat("Errors while applying transformations: ", e.getMessage()), e); } long transformTime = System.currentTimeMillis() - startingTime; task.log(concat("Transform time: ", String.valueOf(transformTime), " ms")); delete(outputFile); }
/** * Create an instance of an XSL parameter for configuration by Ant. * * @return an instance of the Param class to be configured. * @since Ant 1.7 */ public XSLTProcess.Param createParam() { return xsltTask.createParam(); }
/** * constructor creating the transformer from the junitreport task. * @param task task delegating to this class */ public AggregateTransformer(Task task) { this.task = task; xsltTask = new XSLTProcess(); xsltTask.bindToOwner(task); }
private void setXslResource(XSLTProcess task) { Path path = new Path(getProject(), null); Resource resource = new JavaResource(getDefaultName() + ".xsl", path); resource.setProject(getProject()); task.setXslResource(resource); }
private void genreport(ResolutionCacheManager cache, String organisation, String module) throws IOException { // first process the report with xslt XSLTProcess xslt = new XSLTProcess(); xslt.setTaskName(getTaskName()); xslt.setProject(getProject()); xslt.init(); String resolveId = ResolveOptions.getDefaultResolveId(new ModuleId(organisation, module)); xslt.setIn(cache.getConfigurationResolveReportInCache(resolveId, "default")); xslt.setOut(new File(getTodir(), outputname + "." + xslext)); xslt.setStyle(xslFile); XSLTProcess.Param param = xslt.createParam(); param.setName("extension"); param.setExpression(xslext); // add the provided XSLT parameters for (Iterator it = params.iterator(); it.hasNext();) { param = (XSLTProcess.Param) it.next(); XSLTProcess.Param realParam = xslt.createParam(); realParam.setName(param.getName()); realParam.setExpression(param.getExpression()); } xslt.execute(); }
private XSLTProcess xsltTask() { XSLTProcess xsltTask = new XSLTProcess(); xsltTask.bindToOwner(task); xsltTask.setClasspath(classpath); xsltTask.setXslResource(getStylesheet()); xsltTask.setIn(((XMLResultAggregator) task).getDestinationFile()); return xsltTask; }
/** * Performs the XSLT transformation to generate the HTML report. * * @throws BuildException thrown if something goes wrong with the transformation. */ @Override public void transform() throws BuildException { checkOptions(); TempFile tempFileTask = tempFileTask(); XSLTProcess xsltTask = xsltTask(); File outputFile = outputFile(tempFileTask); xsltTask.setOut(outputFile); createNewParams(xsltTask); createOutputDirParam(xsltTask); long startingTime = System.currentTimeMillis(); try { xsltTask.execute(); } catch (Exception e) { throw new BuildException(concat("Errors while applying transformations: ", e.getMessage()), e); } long transformTime = System.currentTimeMillis() - startingTime; task.log(concat("Transform time: ", String.valueOf(transformTime), " ms")); delete(outputFile); }
private void createOutputDirParam(XSLTProcess xsltTask) { Param p = xsltTask.createParam(); p.setProject(task.getProject()); p.setName("output.dir"); p.setExpression(toDir.getAbsolutePath()); }
private void createOutputDirParam(XSLTProcess xsltTask) { Param p = xsltTask.createParam(); p.setProject(task.getProject()); p.setName("output.dir"); p.setExpression(toDir.getAbsolutePath()); }
/** * Set the optional classpath to the XSL processor * * @param classpath the classpath to use when loading the XSL processor */ public void setClasspath(final Path classpath) { createClasspath().append(classpath); }
private void createNewParams(XSLTProcess xsltTask) { for (Param param : params) { Param p = xsltTask.createParam(); p.setProject(task.getProject()); p.setName(param.getName()); p.setExpression(param.getExpression()); } }
/** * Creates a classpath to be used for the internal XSLT task. * * @return the classpath to be configured * @since Ant 1.9.5 */ public Path createClasspath() { return xsltTask.createClasspath(); }
private void createNewParams(XSLTProcess xsltTask) { for (Param param : params) { Param p = xsltTask.createParam(); p.setProject(task.getProject()); p.setName(param.getName()); p.setExpression(param.getExpression()); } }