try {
String rncFilePath = SchemaConverter.class.getClassLoader().getResource(schemaPath).toString().replace('\\', '/').replaceAll(" ","%20");
InputFormat inputFormat = Formats.createInputFormat("rnc");
OutputFormat outputFormat = Formats.createOutputFormat("rng");
String[] inputOptions = {};
SchemaCollection schemaCollection = inputFormat.load(rncFilePath, inputOptions, "rng", new ErrorHandlerImpl(), null);
OutputDirectory outputDirectory = new LocalOutputDirectory(schemaCollection.getMainUri(), rngOutputFile, "rng", "UTF-8", 72, 2);
String[] outputOptions = {};
outputFormat.output(schemaCollection, outputDirectory, outputOptions, "rnc", new ErrorHandlerImpl());
}
catch(IOException | InputFailedException | InvalidParamsException | SAXException | OutputFailedException e) {
throw new SchemaCreationException(e);
}