InterviewSolution
| 1. |
How Do I Turn On Dtd Validation? |
|
Answer» You can turn validation on and off via methods available on the SAX2 XMLReaderinterface. While only the SAXParser implements the XMLReader interface, the methods REQUIRED for turning on validation are available to both PARSER classes, DOM and SAX. The CODE snippet below shows how to turn validation on -- assume that parser is an instance of EITHER org.apache.xerces.parsers.SAXParser ororg.apache.xerces.parsers.DOMParser. parser.setFeature("HTTP://xml.org/sax/features/validation", true); You can turn validation on and off via methods available on the SAX2 XMLReaderinterface. While only the SAXParser implements the XMLReader interface, the methods required for turning on validation are available to both parser classes, DOM and SAX. The code snippet below shows how to turn validation on -- assume that parser is an instance of either org.apache.xerces.parsers.SAXParser ororg.apache.xerces.parsers.DOMParser. parser.setFeature("http://xml.org/sax/features/validation", true); |
|