1
我使用的是Saxon-B 9.1.0.8和XSL 2.0。如何將參數傳遞給Saxon-B處理的XSL?
我有一個XSL樣式表,其中有一個xsl:param
元素:
<xsl:param name="lang"/>
,我使用下面的代碼做我的文檔的轉換:
try {
Source xmlSource = new StreamSource(new File(xmlFilename));
Source xsltSource = new StreamSource(new File(xslFilename));
// create the transformer
Processor processor = new Processor(false);
XsltCompiler xsltCompiler = processor.newXsltCompiler();
XsltExecutable xslt = xsltCompiler.compile(xsltSource);
XsltTransformer xsltTransformer = xslt.load();
xsltTransformer.setSource(xmlSource);
// configure output
StringWriter sw = new StringWriter();
Serializer serializer = new Serializer();
serializer.setOutputWriter(sw);
serializer.setOutputProperty(Serializer.Property.INDENT, "yes");
xsltTransformer.setDestination(serializer);
// do it!
xsltTransformer.transform();
} catch (SaxonApiException e) {
logger.error(e.getMessage(), e);
}
應如何該參數的值傳遞給變壓器?