private static SAXParserFactory createSAXParserFactory(){
  try {
    SAXParserFactory factory=SAXParserFactory.newInstance();
    try {
      SAXParserFactory secureFactory=SecureGenericXMLFactory.getSAXParserFactory(factory);
      secureFactory.newSAXParser();
      factory=secureFactory;
    }
 catch (    ParserConfigurationException e) {
    }
    factory.setNamespaceAware(true);
    return factory;
  }
 catch (  SAXException e) {
    throw new IllegalStateException("Failed to create a SAX parser factory",e);
  }
}

private static SAXParserFactory createSAXParserFactory ( ) { try { SAXParserFactory factory = SAXParserFactory . newInstance ( ) ; try { SAXParserFactory secureFactory = SecureGenericXMLFactory . getSAXParserFactory ( factory ) ; secureFactory . newSAXParser ( ) ; factory = secureFactory ; } catch ( ParserConfigurationException e ) { } factory . setNamespaceAware ( true ) ; return factory ; } catch ( SAXException e ) { throw new IllegalStateException ( "Failed to create a SAX parser factory" , e ) ; } }
creates a secure sax parser , which is secured against xxe attacks .
