예제 #1
0
 public void prepare(Path path) throws ValidatorException {
   try {
     transformer = transformerFactory.newTransformer(new StreamSource(Files.newInputStream(path)));
     jaxbResult = new JAXBResult(JAXBContext.newInstance(SchematronOutput.class));
   } catch (Exception e) {
     throw new ValidatorException(e.getMessage(), e);
   }
 }
예제 #2
0
  @Override
  public void check(Document document, Section section) throws ValidatorException {
    long tsStart = System.currentTimeMillis();
    try {
      transformer.transform(new StreamSource(document.getInputStream()), jaxbResult);
      long tsEnd = System.currentTimeMillis();

      SchematronOutput output = (SchematronOutput) jaxbResult.getResult();

      section.setTitle(output.getTitle());
      section.setRuntime((tsEnd - tsStart) + "ms");

      for (Object o : output.getActivePatternAndFiredRuleAndFailedAssert())
        if (o instanceof FailedAssert) add(section, (FailedAssert) o);
    } catch (Exception e) {
      throw new ValidatorException(String.format("Unable to perform check: %s", e.getMessage()), e);
    }
  }