static Parser makeParser(boolean validate) { SAXParserFactory factory = makeParserFactory(validate, false); try { return factory.newSAXParser().getParser(); } catch (ParserConfigurationException ex) { notifyNewSAXParserEx(ex); return null; } catch (SAXException ex) { notifyNewSAXParserEx(ex); return null; } }
/** Return XML reader or null if no provider exists. */ static XMLReader makeXMLReader(boolean validating, boolean namespaces) { SAXParserFactory factory = makeParserFactory(validating, namespaces); try { return factory.newSAXParser().getXMLReader(); } catch (ParserConfigurationException ex) { notifyNewSAXParserEx(ex); return null; } catch (SAXException ex) { notifyNewSAXParserEx(ex); return null; } }
private static SAXParserFactory makeParserFactory(boolean validating, boolean ns) { SAXParserFactory factory = null; // create factory according to javax.xml.parsers.SAXParserFactory property // or platform default (i.e. com.sun...) try { factory = SAXParserFactory.newInstance(); factory.setValidating(validating); factory.setNamespaceAware(ns); } catch (FactoryConfigurationError err) { notifyFactoryErr(err, "javax.xml.parsers.SAXParserFactory"); // NOI18N throw err; } return factory; }