Onderhoud Wegens upgrade omwille van een kritieke kwetsbaarheid zal confluence vandaag (18/12/2023) om 14u00 even onbeschikbaar zijn.
...
Codeblok | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
import javax.xml.XMLConstants; import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; import javax.xml.validation.*; import java.net.URL; import java.net.MalformedURLException; import org.xml.sax.SAXException; //import java.io.File; // Als er gebruik wordt gemaakt van een XSD-file ipv een URL import java.io.IOException; ... URL schemaFile = new URL("https://www.dov.vlaanderen.be/xdov/schema/latest/xsd/kern/dov.xsd"); // Andere schema's kunnen gevonden worden op https://www.dov.vlaanderen.be/portaal/?module=ocdov-xdov-validate // Voorbeeld met een lokaal bestand: // File schemaFile = new File("/location/to/localfile.xsd"); Source xmlFile = new StreamSource(new File("C:\\<PAD_NAAR_XML>\\mijn_xml.xml")); SchemaFactory schemaFactory = SchemaFactory .newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); try { Schema schema = schemaFactory.newSchema(schemaFile); Validator validator = schema.newValidator(); validator.validate(xmlFile); System.out.println(xmlFile.getSystemId() + " is geldig"); } catch (SAXException e) { System.out.println(xmlFile.getSystemId() + " is NIET geldig. Reden:" + e); } catch (IOException e) {} |
...
XML validatie via DOV-webservices
Aan te spreken url: https://services.dov.vlaanderen.be/dov-xdov-server/import/validate (Type request: POST, Header: Content-Type: application/json)
...