Code example for SAXParserFactory

Methods: newSAXParser, setFeature, setNamespaceAware, setValidating

0
		// SAX2 namespace-prefixes should be true for either builder 
		setSafeFeature(fty, "http://xml.org/sax/features/namespace-prefixes", true);
 
		// Set SAX2 namespaces feature appropriately 
		setSafeFeature(fty, "http://xml.org/sax/features/namespaces", nsaware);
		fty.setNamespaceAware(nsaware);
 
		setSafeFeature(fty, "http://xml.org/sax/features/validation", validate);
		setSafeFeature(fty, "http://apache.org/xml/features/validation/schema", validate);
		fty.setValidating(validate);
 
		_parser = fty.newSAXParser();
	} 
	private static 
	void setSafeFeature(SAXParserFactory fty, String feature, boolean value) {
		try { 
			fty.setFeature(feature, value);
		} catch (Throwable ex) {
			//IGNORE IT (crimson doesn't support ...validation/schema) 
			if (feature.startsWith("http://xml.org"))
				log.warning("Ignored: "+fty+" doesn't support "+feature+". Cause: "+Exceptions.getMessage(ex));
		}