public void add(Section section, FailedAssert failedAssert) {
    AssertionType assertionType = new AssertionType();

    String text =
        failedAssert.getText().replaceAll("\n", "").replaceAll("\r", "").replaceAll("\t", "");
    if (text.startsWith("[") && text.contains("]-")) {
      assertionType.setIdentifier(text.substring(1, text.indexOf("]-")).trim());
      text = text.substring(text.indexOf("]-") + 2).trim();
    } else {
      assertionType.setIdentifier("UNKNOWN");
    }

    assertionType.setText(text);
    assertionType.setLocation(failedAssert.getLocation());
    assertionType.setTest(failedAssert.getTest());

    switch (failedAssert.getFlag()) {
      case "fatal":
        assertionType.setFlag(FlagType.ERROR);
        break;
      case "warning":
        assertionType.setFlag(FlagType.WARNING);
        break;
      default:
        logger.warn("Unknown: " + failedAssert.getFlag());
        break;
    }

    section.add(assertionType);
  }
  @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);
    }
  }