Source stylesheetSource = new StreamSource(new ByteArrayInputStream(prettyPrintStylesheet.getBytes()));
Source xmlSource = new StreamSource(inputStream);
TransformerFactory tf = TransformerFactory.newInstance();
Templates templates = tf.newTemplates(stylesheetSource);
Transformer transformer = templates.newTransformer();
transformer.setErrorListener(new ErrorListener(){
public void warning(TransformerException exception) throws TransformerException {
log.warn("Exception occurred while trying to pretty print file " + file, exception);
}