}
}
public XProcConfiguration createConfiguration() throws SaxonApiException {
checkArgs();
XProcConfiguration config = null;
// Blech
try {
String proc = saxonProcessor;
if (schemaAware) {
proc = "ee";
}
if (saxonConfig != null) {
config = new XProcConfiguration(saxonConfig);
} else if (proc != null) {
config = new XProcConfiguration(proc, schemaAware);
} else {
config = new XProcConfiguration();
}
} catch (Exception e) {
err.println("FATAL: Failed to parse Saxon configuration file.");
err.println(e);
exit(2);
}
if (this.config != null) {
try {
InputStream instream;
switch (this.config.getKind()) {
case URI:
URI furi = URI.create(this.config.getUri());
instream = new FileInputStream(new File(furi));
break;
case INPUT_STREAM:
instream = this.config.getInputStream();
break;
default:
throw new UnsupportedOperationException(format("Unsupported config kind '%s'", this.config.getKind()));
}
SAXSource source = new SAXSource(new InputSource(instream));
// No resolver, we don't have one yet
DocumentBuilder builder = config.getProcessor().newDocumentBuilder();
XdmNode doc = builder.build(source);
config.parse(doc);
} catch (Exception e) {
err.println("FATAL: Failed to parse configuration file.");
err.println(e);
exit(3);
}