4P-
POLITECHNIKA RZESZOWSKA - Wydział Elektrotechniki I Informatyki
Import javax.xml.transform.*; import javax.xml.transform.stream.*; import javax.x.ml .validation.*; import org.xml.sax.*; public class XMLSchemaValidator {
public static void main(StringlJ args) { try (
String schemaLang = "http://www.w3.org/2001/XMLSohama”;
SchemaFactory factory = SchemaFactory-newlnstanoe(schemaLang); Schema schema = factory.newSchema(new
StreamSource("mySahamaFile.xsd")); Validator validator = schema.newValidator();
Source source = new StreamSource("myXmlFile.xml"); validator.validate(source);
System.out.println("Document is valid I");
) catch (SAXException ex) {
System.out.println("Document i8 not valid because:\n" +
ex.getMessage());
} catch (Exception e) ( e.printStackTraceO; }
}
' l.bfiyrkjhl )r) /U12 J&h WUKUP—