POLITECHNIKA
RZESZOWSK.
- Wydział Elektrotechniki i Informatyki
import javax.xml.transform.*; import javax.xml.transform.stream.*; import j avax.xml.validation.*; import org.xml.sax.*; public class XMLSchemaValidator {
public static void main(String[] args) ( try {
String schemaLang = "http://www.w3.org/2001/XMLSchenia";
SchemaFactory factory = SchemaFactory.newlnstanoe(schemaLang); Schema schema = factory.newSchema(new
StreamSource I "mySchemaFile.xsd"));
Validator validator = schema.newValidator();
Source source = new StreamSource("myXmlFile.xml"); validator.validate(source);
System.out.println("Document is valid !");
} catch (SAXException ex) {
ex.getMessage());
) catch (Exception e) { e.printStackTraceO; j
System.out-println("Document is not valid because:\n" +
}
Cópyrighfi J01J ian Vf/mUt>'