code: public boolean validate(final ValidationMethod method, final String xml, final String fileName, final byte[] data,
              final String entities, final String rootEleName, final Map<String, byte[]> additionalFiles) {
          if (xml == null || fileName == null || data == null || rootEleName == null) return false;
  
          files = new HashMap<String, byte[]>();
          files.put(fileName, data);
          if (additionalFiles != null) {
              files.putAll(additionalFiles);
          }
  
          String encoding = XMLUtilities.findEncoding(xml);
          if (encoding == null) encoding = "UTF-8";
  
          try {
              final Resolver resolver = new Resolver(files);
              if (method == ValidationMethod.DTD) {
                  final byte[] xmlData = setXmlPreambleAndDTD(xml, fileName, entities, rootEleName).getBytes(encoding);
                  validateDTD(resolver, xmlData);
              } else {
                  final byte[] xmlData = setXmlPreambleAndDTD(xml, null, entities, rootEleName).getBytes(encoding);
                  validateSchema(method, resolver, data, xmlData);
              }
          } catch (SAXParseException e) {
              handleError(e);
              return false;
          } catch (Exception e) {
              LOG.error("An error occurred validating the XML", e);
              return false;
          }
          return true;
      }
docs: Validates some piece of XML to ensure that it is valid.
  
  @param method          The validation method to use during validation.
  @param xml             The XML to be validated.
  @param fileName        The filename of the DTD data.
  @param data            The DTD data to be used to validate against.
  @param entities        The entity data to be used to validate against.
  @param rootEleName     The name of the root XML Element.
  @param additionalFiles Any additional files that are needed during the validation.
  @return True if the XML is valid, otherwise false.