void (SchemaType inputType, IdeaErrorHandler errorHandler, VirtualFile... inputFiles) { if (inputFiles.length == 0) { throw new IllegalArgumentException(); } try { final InputFormat inFormat = getInputFormat(inputType); if (inputFiles.length > 1) { if (!(inFormat instanceof MultiInputFormat)) { throw new IllegalArgumentException(); } } final VirtualFile inputFile = inputFiles[0]; final SchemaType type = settings.getOutputType(); final String outputType = StringUtil.toLowerCase(type.toString()); final ArrayList<String> inputParams = new ArrayList<>(); if (inputType != SchemaType.DTD) { final Charset charset = inputFile.getCharset(); inputParams.add("encoding=" + charset.name()); } final ArrayList<String> outputParams = new ArrayList<>(); settings.addAdvancedSettings(inputParams, outputParams); // System.out.println("INPUT: " + inputParams); // System.out.println("OUTPUT: " + outputParams); final SchemaCollection sc; final String input = inputFile.getPath(); final String uri = UriOrFile.toUri(input); try { if (inFormat instanceof MultiInputFormat format) { final String[] uris = new String[inputFiles.length]; for (int i = 0; i < inputFiles.length; i++) { uris[i] = UriOrFile.toUri(inputFiles[i].getPath()); } sc = format.load(uris, ArrayUtilRt.toStringArray(inputParams), outputType, errorHandler); } else { sc = inFormat.load(uri, ArrayUtilRt.toStringArray(inputParams), outputType, errorHandler); } } catch (IOException e) { errorHandler.fatalError(new SAXParseException(e.getMessage(), null, uri, -1, -1, e)); return; } final File destination = new File(settings.getOutputDestination()); final File outputFile; if (destination.isDirectory()) { final String name = new File(input).getName(); final int ext = name.lastIndexOf('.'); outputFile = new File(destination, (ext > 0 ? name.substring(0, ext) : name) + "." + outputType); } else { outputFile = destination; } try { final int indent = settings.getIndent(); final int length = settings.getLineLength(); final OutputDirectory od = new LocalOutputDirectory(sc.getMainUri(), outputFile, "." + outputType, settings.getOutputEncoding(), length > 0 ? length : DEFAULT_LINE_LENGTH, indent > 0 ? indent : DEFAULT_INDENT) { @Override public Stream open(String sourceUri, String encoding) throws IOException { final String s = reference(null, sourceUri); final File file = new File(outputFile.getParentFile(), s); if (file.exists()) { final String msg = RelaxngBundle.message("relaxng.convert-schema.dialog.file-exists.message", file.getAbsolutePath()); final int choice = Messages.showYesNoDialog(myProject, msg, RelaxngBundle.message( "relaxng.convert-schema.dialog.file-exists.title"), Messages.getWarningIcon()); if (choice == Messages.YES) { return super.open(sourceUri, encoding); } else if (choice == 1) { throw new CanceledException(); } } return super.open(sourceUri, encoding); } }; final OutputFormat of = getOutputFormat(settings.getOutputType()); of.output(sc, od, ArrayUtilRt.toStringArray(outputParams), StringUtil.toLowerCase(inputType.toString()), errorHandler); } catch (IOException e) { errorHandler.fatalError(new SAXParseException(e.getMessage(), null, UriOrFile.fileToUri(outputFile), -1, -1, e)); } } catch (CanceledException e) { // user abort } catch (SAXParseException e) { errorHandler.error(e); } catch (MalformedURLException e) { Logger.getInstance(getClass().getName()).error(e); } catch (InputFailedException | OutputFailedException | InvalidParamsException e) { // handled by ErrorHandler } catch (SAXException e) { // cannot happen or is already handled } }