String rngSchemaName = schemaPath.substring(schemaPath.lastIndexOf('/') + 1).replaceAll("\\.rnc$", ".rng");
File rngOutputFile = new File(Files.createTempDir(), rngSchemaName);
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());
}