Code example for Schema

Methods: newValidator

0
				.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
		try 
		{ 
			Schema schema = sf.newSchema(new StreamSource(
					"E:\\Workspace\\RealTimeWrapper.xsd")); 
			Validator validator = schema.newValidator();
			validator.validate(new StreamSource("E:\\Workspace\\b.xml"));
		} 
		catch (SAXException e)
		{ 
			e.printStackTrace();
			System.out.println("invalid\\n");
			return; 
		} 
		catch (IOException e)
		{ 
			e.printStackTrace();
			System.out.println("invalid\\n");
			return; 
		} 
		System.out.println("It is valid\\n");