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 ) ; } }
Called for parsing or validating a single file .