code: public void validateWithDtd(String filename, String dtdPath, String docType) throws IOException {
      try (InputStream xmlStream = this.getClass().getResourceAsStream(filename)) {
        if (xmlStream == null) {
          throw new IOException("Not found in classpath: " + filename);
        }
        try {
          String xml = StringTools.readStream(xmlStream, "utf-8");
          validateInternal(xml, dtdPath, docType);
        } catch (Exception e) {
          throw new IOException("Cannot load or parse '" + filename + "'", e);
        }
      }
    }
docs: Validate XML file in classpath with the given DTD. Throws exception on error.