code: public List<SAXParseException> validate(File file, CycloneDxSchema.Version schemaVersion) {
          final Source xmlFile = new StreamSource(file);
          final List<SAXParseException> exceptions = new LinkedList<>();
          try {
              final Schema schema = getXmlSchema(schemaVersion);
              final Validator validator = schema.newValidator();
              validator.setErrorHandler(new ErrorHandler() {
                  @Override
                  public void warning(SAXParseException exception) {
                      exceptions.add(exception);
                  }
                  @Override
                  public void fatalError(SAXParseException exception) {
                      exceptions.add(exception);
                  }
                  @Override
                  public void error(SAXParseException exception) {
                      exceptions.add(exception);
                  }
              });
              validator.validate(xmlFile);
          } catch (IOException | SAXException e) {
              // throw it away
          }
          return exceptions;
      }
docs: Verifies a CycloneDX BoM conforms to the specification through XML validation.
  @param file the CycloneDX BoM file to validate
  @param schemaVersion the schema version to validate against
  @return a List of SAXParseExceptions. If the size of the list is 0, validation was successful
  @since 2.0.0