Document parse ( Document doc , Element instruction , PrintWriter logger ) throws Exception { this . outputLogger = logger ; if ( instruction != null ) { getFileType ( instruction ) ; if ( type . equals ( "url" ) ) { URL schemaURL = new URL ( this . schemaLocation ) ; this . schemaFile = new File ( schemaURL . toURI ( ) ) ; } else if ( type . equals ( "file" ) ) { this . schemaFile = new File ( this . schemaLocation ) ; } else if ( type . equals ( "resource" ) ) { URL url = this . getClass ( ) . getResource ( this . schemaLocation ) ; this . schemaFile = new File ( URLDecoder . decode ( url . getFile ( ) , "UTF-8" ) ) ; } } boolean isValid = false ; if ( doc != null ) { InputSource xmlInputSource = null ; try { InputStream inputStream = DocumentToInputStream ( doc ) ; xmlInputSource = new InputSource ( inputStream ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } isValid = executeSchematronDriver ( xmlInputSource , this . schemaFile , this . phase ) ; } if ( ! isValid ) { return null ; } else { return doc ; } }
Checks the given Document against a Schematron schema . A schema reference is conveyed by a DOM Element node as indicated below .