public void validate(String message, CombinedXmlValidationProfile profile) throws ValidationException { requireNonNull(profile, "validation profile must be not null"); // check whether the root element name is valid String rootElementName = rootElementName(requireNonNull(message, "message must be not null")); if (! profile.isValidRootElement(rootElementName)) { throw new ValidationException("Invalid root element '" + rootElementName + "'"); } // XSD validation String xsdPath = profile.getXsdPath(rootElementName); if (xsdPath != null) { XSD_VALIDATOR.validate(source(message), xsdPath); } // Schematron validation String schematronPath = profile.getSchematronPath(rootElementName); if (schematronPath != null) { SchematronProfile schematronProfile = new SchematronProfile( schematronPath, profile.getCustomSchematronParameters(rootElementName)); SCHEMATRON_VALIDATOR.validate(source(message), schematronProfile); } } }