code: private void validate( final Resolver pResolver, ValidationSet pValidationSet, Schema pSchema, File pFile, ValidationErrorHandler errorHandler )
          throws MojoExecutionException
      {
          errorHandler.setContext(pFile);
          try
          {
              if ( pSchema == null )
              {
                  getLog().debug( "Parsing " + pFile.getPath() );
                  parse( pResolver, pValidationSet, pFile ,errorHandler);
              }
              else
              {
                  getLog().debug( "Validating " + pFile.getPath() );
                  Validator validator = pSchema.newValidator();
                  validator.setErrorHandler(errorHandler);
                  if ( pResolver != null )
                  {
                      validator.setResourceResolver( pResolver );
                  }
                  
                  if ( pValidationSet.isXincludeAware() )
                  {
                      SAXParserFactory spf = SAXParserFactory.newInstance();
                      spf.setNamespaceAware( true );
                      spf.setXIncludeAware( pValidationSet.isXincludeAware() );
  
                      InputSource isource = new InputSource( pFile.toURI().toASCIIString() );
                      XMLReader xmlReader = spf.newSAXParser().getXMLReader();
                      xmlReader.setEntityResolver( pResolver );
                      
                      validator.validate( new SAXSource( xmlReader, isource ) );
                  }
                  else
                  {
                      validator.validate( new StreamSource( pFile ) );
                  }
              }
          }
          catch ( SAXParseException e )
          {
              try{
                  errorHandler.fatalError(e);
              }
              catch(SAXException se){
                  throw new MojoExecutionException( "While parsing " + pFile + ": " + e.getMessage(), se );
              }
          }
          catch ( Exception e )
          {
              throw new MojoExecutionException( "While parsing " + pFile + ": " + e.getMessage(), e );
          }
      }
docs: Called for parsing or validating a single file.
  
  @param pResolver The resolver to use for loading external entities.
  @param pValidationSet The parsers or validators configuration.
  @param pSchema The schema to use.
  @param pFile The file to parse or validate.
  @throws MojoExecutionException Parsing or validating the file failed.