public Document parse(URLConnection uc, Element instruction, PrintWriter logger) throws Exception { Document doc = null; ErrorHandlerImpl eh = new ErrorHandlerImpl(null, logger); String old_config_property = System.getProperty(config_property); System.clearProperty(config_property); try { DocumentBuilder db = DBF.newDocumentBuilder(); db.setErrorHandler(eh); doc = db.parse(uc.getInputStream()); } catch (Exception e) { logger.println(e.getMessage()); } if (old_config_property != null) { System.setProperty(config_property, old_config_property); } if (eh.getErrorCount() > 0 || eh.getWarningCount() > 0) { logger.println(eh.getErrorCounts()); logger.flush(); } if (eh.getErrorCount() > 0) { return null; } return doc; }
loadSchemaLists(parserConfig, schemas, dtds); Document resultDoc = null; ErrorHandlerImpl errHandler = new ErrorHandlerImpl("Parsing", logger);
loadSchemaLists(parserConfig, schemas, dtds); Document resultDoc = null; ErrorHandlerImpl errHandler = new ErrorHandlerImpl("Parsing", logger);
ErrorHandlerImpl eh = new ErrorHandlerImpl("Parsing", logger);
/** * Sets up the schematron reader with all the necessary parameters. Calls * initSchematronReader() to do further setup of the validation driver. * * @param phase * The string phase name (contained in schematron file) * @return The ValidationDriver to use in validating the XML document */ ValidationDriver createSchematronDriver(String phase) { SchemaReaderLoader loader = new SchemaReaderLoader(); SchemaReader schReader = loader.createSchemaReader(SCHEMATRON_NS_URI); this.configPropBuilder = new PropertyMapBuilder(); SchematronProperty.DIAGNOSE.add(this.configPropBuilder); if (this.outputLogger == null) { this.outputLogger = new PrintWriter(System.out); } if (null != phase && !phase.isEmpty()) { this.configPropBuilder.put(SchematronProperty.PHASE, phase); } ErrorHandler eh = new ErrorHandlerImpl("Schematron", outputLogger); this.configPropBuilder.put(ValidateProperty.ERROR_HANDLER, eh); ValidationDriver validator = new ValidationDriver( this.configPropBuilder.toPropertyMap(), schReader); return validator; }
/** * Sets up the schematron reader with all the necessary parameters. Calls * initSchematronReader() to do further setup of the validation driver. * * @param phase * The string phase name (contained in schematron file) * @return The ValidationDriver to use in validating the XML document */ ValidationDriver createSchematronDriver(String phase) { SchemaReaderLoader loader = new SchemaReaderLoader(); SchemaReader schReader = loader.createSchemaReader(SCHEMATRON_NS_URI); this.configPropBuilder = new PropertyMapBuilder(); SchematronProperty.DIAGNOSE.add(this.configPropBuilder); if (this.outputLogger == null) { this.outputLogger = new PrintWriter(System.out); } if (null != phase && !phase.isEmpty()) { this.configPropBuilder.put(SchematronProperty.PHASE, phase); } ErrorHandler eh = new ErrorHandlerImpl("Schematron", outputLogger); this.configPropBuilder.put(ValidateProperty.ERROR_HANDLER, eh); ValidationDriver validator = new ValidationDriver( this.configPropBuilder.toPropertyMap(), schReader); return validator; }
ErrorHandlerImpl eh = new ErrorHandlerImpl("Parsing", logger);