4.5. XML Validation
Most XML parsers provide a validation capability. Validation means that beyond just ensuring that the XML is well-formed, the parser will also verify that the XML document conforms to the DTD or XML Schema. Unfortunately, telling a parser whether or not it should use validation is one of the things that is implementation-dependent, so there is no portable way to turn validation on or off.
For the Apache Xerces parser, validation is turned on and off by a setFeature() method. For SAX, you can call setFeature() on the org.xml.sax.XMLReader object (if you're using JAXP, you can obtain a reference to this object by calling the getXMLReader() method of the javax.xml.parsers.SAXParser object). For DOM, you must call the setFeature() ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access