public boolean validate ( InputSource in ) throws SAXException , IOException { if ( schema == null ) throw new IllegalStateException ( "cannot validate without schema" ) ; if ( validator == null ) validator = schema . createValidator ( instanceProperties ) ; if ( xr == null ) { xr = ResolverFactory . createResolver ( instanceProperties ) . createXMLReader ( ) ; xr . setErrorHandler ( eh ) ; } eh . reset ( ) ; xr . setContentHandler ( validator . getContentHandler ( ) ) ; DTDHandler dh = validator . getDTDHandler ( ) ; if ( dh != null ) xr . setDTDHandler ( dh ) ; try { xr . parse ( in ) ; return ! eh . getHadErrorOrFatalError ( ) ; } finally { validator . reset ( ) ; } }
Validates a document against the currently loaded schema . This can be called multiple times in order to validate multiple documents .