/** * Transform summary information to HTML. * * @param htmlWriter * the Writer to write the HTML output to */ public void transformSummaryToHTML(Writer htmlWriter) throws IOException, TransformerException { ByteArrayOutputStream summaryOut = new ByteArrayOutputStream(8096); reportSummary(summaryOut); StreamSource in = new StreamSource(new ByteArrayInputStream(summaryOut.toByteArray())); StreamResult out = new StreamResult(htmlWriter); InputStream xslInputStream = this.getClass().getClassLoader().getResourceAsStream("summary.xsl"); if (xslInputStream == null) { throw new IOException("Could not load summary stylesheet"); } StreamSource xsl = new StreamSource(xslInputStream); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(xsl); transformer.transform(in, out); Reader rdr = in.getReader(); if (rdr != null) { rdr.close(); } htmlWriter.close(); InputStream is = xsl.getInputStream(); if (is != null) { is.close(); } }
/** * Transform summary information to HTML. * * @param htmlWriter * the Writer to write the HTML output to */ public void transformSummaryToHTML(Writer htmlWriter) throws IOException, TransformerException { ByteArrayOutputStream summaryOut = new ByteArrayOutputStream(8096); reportSummary(summaryOut); StreamSource in = new StreamSource(new ByteArrayInputStream(summaryOut.toByteArray())); StreamResult out = new StreamResult(htmlWriter); InputStream xslInputStream = this.getClass().getClassLoader().getResourceAsStream("summary.xsl"); if (xslInputStream == null) { throw new IOException("Could not load summary stylesheet"); } StreamSource xsl = new StreamSource(xslInputStream); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(xsl); transformer.transform(in, out); Reader rdr = in.getReader(); if (rdr != null) { rdr.close(); } htmlWriter.close(); InputStream is = xsl.getInputStream(); if (is != null) { is.close(); } }