Transformer transformer = factory.newTransformer(new StreamSource(xsl));
// now lets create the TrAX source and result
// objects and do the transformation
Source source = new DocumentSource(document);
DocumentResult result = new DocumentResult();
transformer.transform(source, result);
// output the transformed document
Document transformedDoc = result.getDocument();
writer.write(transformedDoc);
}