private void prettyprint ( String xmlLogsFile , FileOutputStream htmlReportFile ) throws Exception { TransformerFactory tFactory = TransformerFactory . newInstance ( ) ; // Fortify Mod: prevent external entity injection tFactory . setFeature ( XMLConstants . FEATURE_SECURE_PROCESSING , true ) ; DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance ( ) ; // Fortify Mod: prevent external entity injection factory . setExpandEntityReferences ( false ) ; factory . setNamespaceAware ( true ) ; factory . setXIncludeAware ( true ) ; DocumentBuilder parser = factory . newDocumentBuilder ( ) ; Document document = parser . parse ( xmlLogsFile ) ; Transformer transformer = tFactory . newTransformer ( new StreamSource ( xsltFileHandler ) ) ; transformer . transform ( new DOMSource ( document ) , new StreamResult ( htmlReportFile ) ) ; }
Apply xslt stylesheet to xml logs file and crate an HTML report file .