POLITECHNIKA RZESZOWSKA - Wydział Elektrotechniki I Informatyki
try {
String schemaLang = "http://www.w3.org/2001/XMLSchema"; SchemaFactory jaxp = SchemaFactory.newlnstanoe(schemaLang); Schema schema = jaxp.newScheraa(new
StreamSource("mySohemaFile.xsd")); Validator validator = schema.newValidator();
SaxHandler handler = new SaxHandler();
SAXResult result = new SAXResult(handler);
SAXSource source = new SAXSource(new
InputSource("myXmlFile.xml")); validator.valida te (source, result); | Walidacja |
System.out.println("Document is valid !");
) catch (SAXException ex) {
System.out.println("Document is not valid because:\n" +
ex.getMessage ());
) catch (Exception ex) (ex.printStackTrace();)
private static finał class SaxHandler extends Del