114 Chapter 3 • Processing XML Documents with DOM
Note that the servlet’s doGet() method uses this instance using a synchronized() block:
returnValue = myParser.returnResult();
Since the DocumentBuilderFactory class in itself is not thread-safe, the code may behave erratically or exceptions/errors may be thrown.
public void setFeature(String name, boolean value) throws
If the parser cannot recognize a feature, the SAXNotRecognizedException is thrown. If the parser is not equipped to support the feature, a
SAXNotSupportedException is thrown.
SAX parsers do not have any of the properties required. However, the XMLReader interface provides two methods, setProperty() and getProperty(),to set and to retrieve the parser properties:
For example, to set the schema location for elements that are not in any namespace of http://www.propertyexample.com/schema.xsd, the following code may be used: