protected static XmlNamespaceFinder createNamespaceFinder() { XmlNamespaceFinder finder = new XmlNamespaceFinder(); if (factory != null) { finder.setFactory(factory); } return finder; }
/** * Returns the namespace URIs found in the given XML file */ public static Set<String> getNamespaces(InputSource source) throws ParserConfigurationException, SAXException, IOException { XmlNamespaceFinder finder = createNamespaceFinder(); Set<String> answer = finder.parseContents(source); if (factory == null) { factory = finder.getFactory(); } return answer; }
public Set<String> parseContents(InputSource contents) throws IOException, ParserConfigurationException, SAXException { namespaces.clear(); // Parse the file into we have what we need (or an error occurs). if (factory == null) { factory = SAXParserFactory.newInstance(); } if (factory != null) { SAXParser parser = createParser(factory); // to support external entities specified as relative URIs (see bug 63298) contents.setSystemId("/"); //$NON-NLS-1$ parser.parse(contents, this); } return namespaces; }