String phase = getOption(_phase).getString();
schemaCompiler.setParameter(new QName("","phase"), new XdmAtomicValue(phase));
}
for (QName name : params.keySet()) {
RuntimeValue v = params.get(name);
schemaCompiler.setParameter(name, new XdmAtomicValue(v.getString()));
}
schemaCompiler.setInitialContextNode(theSchema2_sch);
result = new XdmDestination();
schemaCompiler.setDestination(result);
runtime.getConfigurer().getSaxonConfigurer().configSchematron(schemaCompiler.getUnderlyingController().getConfiguration());
schemaCompiler.transform();
XdmNode compiledSchema = result.getXdmNode();
XdmNode compiledRoot = S9apiUtils.getDocumentElement(compiledSchema);
if (compiledRoot == null) {
XdmNode schemaRoot = S9apiUtils.getDocumentElement(schemaXML);
String root = schemaRoot == null ? "null" : schemaRoot.getNodeName().toString();
throw new XProcException("p:validate-with-schematron failed to compile provided schema: " + root);
}
XsltTransformer transformer;
compiler = runtime.getProcessor().newXsltCompiler();
compiler.setSchemaAware(schemaAware);
exec = compiler.compile(compiledSchema.asSource());
transformer = exec.load();
for (QName name : params.keySet()) {
RuntimeValue v = params.get(name);
transformer.setParameter(name, new XdmAtomicValue(v.getString()));
}
transformer.setInitialContextNode(sourceXML);
result = new XdmDestination();
transformer.setDestination(result);
transformer.transform();