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);
   }
 }
  @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);
    }
  }