/** * Supply an initial template for a transformation. * <p>This is a Saxon extension to the JAXP interface, needed for XSLT 2.0</p> * <p>Changed in 9.9 so it no longer validates the supplied name; an incorrect name will * lead to an error later.</p> * * @param name the name of the initial template, in Clark notation (either a local name, * or "{uri}local") */ public void setInitialTemplate(String name) { xsltTransformer.setInitialTemplate(QName.fromClarkName(name)); }
/** * Supply an initial template for a transformation. * <p>This is a Saxon extension to the JAXP interface, needed for XSLT 2.0</p> * <p>Changed in 9.9 so it no longer validates the supplied name; an incorrect name will * lead to an error later.</p> * * @param name the name of the initial template, in Clark notation (either a local name, * or "{uri}local") */ public void setInitialTemplate(String name) { xsltTransformer.setInitialTemplate(QName.fromClarkName(name)); }
private void writeSummaryReport(Set<String> testNames, File reportDir) { try { XsltTransformer formatter = xspecHtmlSummaryFormatterLoader.load(); formatter.setInitialTemplate(new QName("main")); formatter.setParameter(new QName("test-names"), new XdmValue( Collections2.<String,XdmItem>transform( testNames, new Function<String,XdmItem>() { public XdmItem apply(String s) { return new XdmAtomicValue(s); }}))); formatter.setParameter(new QName("report-dir"), new XdmAtomicValue(reportDir.toURI())); formatter.setDestination( serializeToFile(new File(reportDir, "index.html"))); formatter.setMessageListener(SaxonSinkReporter.INSTANCE); formatter.transform(); } catch (SaxonApiException e) { throw new RuntimeException(e); } catch (FileNotFoundException e) { throw new RuntimeException(e); } }
/** * Load the stylesheet to prepare it for execution. This version of the load() method * creates an <code>XsltTransformer</code> which offers interfaces for stylesheet * invocation corresponding to those described in the XSLT 2.0 specification. It can be used * with XSLT 2.0 or XSLT 3.0 stylesheets, but does not offer new XSLT 3.0 functionality such * as the ability to supply parameters to the initial template, or the ability to invoke * stylesheet-defined functions, or the ability to return an arbitrary sequence as a result * without wrapping it in a document node. If such facilities are required, use the * method {@link #load30()} in preference. * * @return An XsltTransformer. The returned XsltTransformer can be used to set up the * dynamic context for stylesheet evaluation, and to run the stylesheet. */ public XsltTransformer load() { XsltTransformer xt = new XsltTransformer( processor, preparedStylesheet.newController(), preparedStylesheet.getCompileTimeParams()); StructuredQName initialTemplate = preparedStylesheet.getDefaultInitialTemplateName(); if (initialTemplate != null) { xt.setInitialTemplate(new QName(initialTemplate)); } return xt; }
/** * Load the stylesheet to prepare it for execution. This version of the load() method * creates an <code>XsltTransformer</code> which offers interfaces for stylesheet * invocation corresponding to those described in the XSLT 2.0 specification. It can be used * with XSLT 2.0 or XSLT 3.0 stylesheets, but does not offer new XSLT 3.0 functionality such * as the ability to supply parameters to the initial template, or the ability to invoke * stylesheet-defined functions, or the ability to return an arbitrary sequence as a result * without wrapping it in a document node. If such facilities are required, use the * method {@link #load30()} in preference. * * @return An XsltTransformer. The returned XsltTransformer can be used to set up the * dynamic context for stylesheet evaluation, and to run the stylesheet. */ public XsltTransformer load() { XsltTransformer xt = new XsltTransformer( processor, preparedStylesheet.newController(), preparedStylesheet.getCompileTimeParams()); StructuredQName initialTemplate = preparedStylesheet.getDefaultInitialTemplateName(); if (initialTemplate != null) { xt.setInitialTemplate(new QName(initialTemplate)); } return xt; }
public void aggregateSpotBugsFiles(File rootDir, int level, File outputDir) throws FileNotFoundException, IOException, SaxonApiException { List<File> spotBugsFiles = getSpotBugsFiles(rootDir, level); Processor proc = new Processor(false); XsltCompiler comp = proc.newXsltCompiler(); InputStream xsl = getClass().getClassLoader().getResourceAsStream("spotbugs/xml-aggregated.xsl"); XsltExecutable exp = comp.compile(new StreamSource(xsl)); Serializer out = proc.newSerializer(new File(outputDir, "SpotBugsAggregated.xml")); out.setOutputProperty(Serializer.Property.METHOD, "xml"); out.setOutputProperty(Serializer.Property.INDENT, "yes"); XsltTransformer trans = exp.load(); List<XdmNode> sources = createXdmNodes(spotBugsFiles, proc.newDocumentBuilder()); QName xmlFiles = new QName("xmlFiles"); XdmValue filesXdm = XdmValue.makeSequence(sources); trans.setParameter(xmlFiles, filesXdm); trans.setInitialTemplate(new QName("test")); trans.setDestination(out); trans.transform(); }
XsltTransformer xspecTestRunner = xspecTestCompiler.compile( compiledTestAsSource).load(); xspecTestRunner.setInitialTemplate(XSPEC_MAIN_TEMPLATE); xspecTestRunner.setDestination(xspecTestResult); xspecTestRunner.setErrorListener(saxonReporter);
transformer.setInitialTemplate(templateName);
transformer.setInitialTemplate(templateName);