Code example for Schema

Methods: newValidator

0
				"planets_wdt.xsd"); 
		try { 
			SchemaFactory factory = SchemaFactory
					.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
			Schema schema = factory.newSchema(new StreamSource(bis));
			Validator validator = schema.newValidator();
			// Validate file against schema 
			XMLOutputter outputter = new XMLOutputter();
			SAXBuilder builder = new SAXBuilder();
			Document doc = builder.build(xmlWFConfig);
			validator.validate(new StreamSource(new StringReader(outputter
					.outputString(doc.getRootElement()))));
		} catch (Exception e) {
			String err = "The provided xmlWFConfig is not valid against the currently used planets_wdt_xsd schema";
			log.debug(err,e);
			throw new Exception (err,e);
		} 
		finally{ 
			bis.close();
		} 
Experience pair programming with AI  Get Codota for Java