import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
/**
* Set of utility methods for instantiating parser that deal with untrusted XML sources.
@Beta
public final class UntrustedXML {
private static final DocumentBuilderFactory DBF;
+
static {
final DocumentBuilderFactory f = DocumentBuilderFactory.newInstance();
f.setCoalescing(true);
}
private static final SAXParserFactory SPF;
+
static {
final SAXParserFactory f = SAXParserFactory.newInstance();
f.setNamespaceAware(true);
f.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
f.setFeature("http://xml.org/sax/features/external-general-entities", false);
f.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
- } catch (final Exception e) {
+ } catch (final SAXNotRecognizedException | SAXNotSupportedException | ParserConfigurationException e) {
throw new ExceptionInInitializerError(e);
}
}
private static final XMLInputFactory XIF;
+
static {
final XMLInputFactory f = XMLInputFactory.newInstance();