try { TransformerFactory xformFactory = TransformerFactory.newInstance(); Source xsl = new StreamSource("stylesheet.xsl"); Transformer stylesheet = xformFactory.newTransformer(xsl); Source request = new StreamSource(in); Result response = new StreamResult(out); stylesheet.transform(request, response); } catch (TransformerException e) { System.err.println(e); }