#-
POLITECHNIKA RZESZOWSKA - Wydział Elektrotechniki i Informatyki
DocumentBuilderFactory dbfactory =
DocumentBuilderFactory.newXn3tance(); dbfactory.setNamespaceAware(t ri
// konieczne !!1 | pa
DocumentBuilder builder = dbfactory.newDocumentBulider(); Document document = builder.parsa(new File("myXmlFil«.xml"));
SchemaFactory factory =
SchemaFactory.newlnstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Source schemaFile = new StreamSource(new File("mySchemaFile.xsd")); Schema schema = factory.newScheraa(schemaFile);
Validator validator = schema.newValidator();
validator.validata(new DOMSource(document));
System.out.println("Document is valid !”);
Element root = document.getDooumentElement() ; | Przetwarzanie
System.out.println("root Element Name: " + root.getTagName());
) catch (SAXException ex) (
System.out.println("Document is not valid:\n"+ ex.getMessage ());
1