QName initialMode = null;
QName templateName = null;
String outputBaseURI = null;
RuntimeValue opt = getOption(_initial_mode);
if (opt != null) {
initialMode = opt.getQName();
}
opt = getOption(_template_name);
if (opt != null) {
templateName = opt.getQName();
}
opt = getOption(_output_base_uri);
if (opt != null) {
outputBaseURI = opt.getString();
}
Processor processor = runtime.getProcessor();
Configuration config = processor.getUnderlyingConfiguration();
runtime.getConfigurer().getSaxonConfigurer().configXSLT(config);
OutputURIResolver uriResolver = config.getOutputURIResolver();
CollectionURIResolver collectionResolver = config.getCollectionURIResolver();
UnparsedTextURIResolver unparsedTextURIResolver = runtime.getResolver();
config.setOutputURIResolver(new OutputResolver());
config.setCollectionURIResolver(new CollectionResolver(runtime, defaultCollection, collectionResolver));
XdmDestination result = null;
try {
XsltCompiler compiler = runtime.getProcessor().newXsltCompiler();
compiler.setSchemaAware(processor.isSchemaAware());
XsltExecutable exec = compiler.compile(stylesheet.asSource());
XsltTransformer transformer = exec.load();
for (QName name : params.keySet()) {
RuntimeValue v = params.get(name);
if (runtime.getAllowGeneralExpressions()) {
transformer.setParameter(name, v.getValue());
} else {
transformer.setParameter(name, new XdmAtomicValue(v.getString()));
}
}
if (document != null) {
transformer.setInitialContextNode(document);