Java tutorial
//package com.java2s; import java.io.File; import java.io.StringReader; import java.io.StringWriter; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; public class Main { public static String getXmlPage(String xmlString, int page, String xslPath) { String styledResponse = ""; StringReader rd = new StringReader(xmlString); StringWriter wrt = new StringWriter(); TransformerFactory tFac = TransformerFactory.newInstance(); try { File xsl = new File(xslPath); Transformer transformer = tFac.newTransformer(new StreamSource(xsl)); transformer.setParameter("Page", String.format("%s", page)); transformer.transform(new StreamSource(rd), new StreamResult(wrt)); styledResponse = wrt.toString(); } catch (TransformerConfigurationException e) { e.printStackTrace(); } catch (TransformerException e) { e.printStackTrace(); } return styledResponse; } }