Java tutorial
//package com.java2s; import java.io.StringWriter; import javax.xml.transform.Source; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Document; public class Main { public static String transform(Source xsl, Document doc) { StringWriter writer = new StringWriter(); try { TransformerFactory.newInstance().newTransformer(xsl).transform(new DOMSource(doc), new StreamResult(writer)); } catch (Exception e) { } return writer.toString(); } }