Here you can find the source of transform(Source xsl, Document doc)
public static String transform(Source xsl, Document doc)
//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 {/*from w w w . j a v a 2 s .c om*/ TransformerFactory.newInstance().newTransformer(xsl).transform(new DOMSource(doc), new StreamResult(writer)); } catch (Exception e) { } return writer.toString(); } }