String version = getConfigs().getString(config, "languageVersion", null);
if (version != null) {
compiler.setXsltLanguageVersion(version);
}
XsltExecutable executable = null;
String query = getConfigs().getString(fragment, "queryString", null);
if (query != null) {
executable = compiler.compile(new StreamSource(new StringReader(query)));
}
String queryFile = getConfigs().getString(fragment, "queryFile", null);
if (queryFile != null) {
executable = compiler.compile(new StreamSource(new File(queryFile)));
}
if (query == null && queryFile == null) {
throw new MorphlineCompilationException("Either query or queryFile must be defined", config);
}
if (query != null && queryFile != null) {
throw new MorphlineCompilationException("Must not define both query and queryFile at the same time", config);
}
XsltTransformer evaluator = executable.load();
Config variables = getConfigs().getConfig(fragment, "parameters", ConfigFactory.empty());
for (Map.Entry<String, Object> entry : new Configs().getEntrySet(variables)) {
XdmValue xdmValue = XdmNode.wrap(new UntypedAtomicValue(entry.getValue().toString()));
evaluator.setParameter(new QName(entry.getKey()), xdmValue);
}