Exemplo n.º 1
0
  private File createSchema(String schemaName)
      throws SAXException, IOException, OutputFailedException, InvalidParamsException,
          InputFailedException, URISyntaxException {
    String rncInputFile =
        getClass()
            .getClassLoader()
            .getResource(schemaName + ".rnc")
            .toString()
            .replace('\\', '/')
            .replaceAll(" ", "%20");
    File rngOutputFile = new File(Files.createTempDir(), schemaName + ".rng");

    InputFormat inputFormat = Formats.createInputFormat("rnc");
    OutputFormat outputFormat = Formats.createOutputFormat("rng");

    String[] inputOptions = {};
    SchemaCollection schemaCollection =
        inputFormat.load(rncInputFile, 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());

    return rngOutputFile;
  }
Exemplo n.º 2
0
 public void output(
     SchemaCollection sc, OutputDirectory od, String[] params, String inputFormat, ErrorHandler eh)
     throws SAXException, IOException, OutputFailedException, InvalidParamsException {
   new OutputDirectoryParamProcessor(od).process(params, eh);
   try {
     ErrorReporter er = new ErrorReporter(eh, RncOutputFormat.class);
     for (Map.Entry<String, SchemaDocument> entry : sc.getSchemaDocumentMap().entrySet()) {
       outputPattern(entry.getValue(), entry.getKey(), od, er);
     }
   } catch (ErrorReporter.WrappedSAXException e) {
     throw e.getException();
   }
 }