, Saxon libs java.
public static String transformXML(String xmlData, String xslFile) throws SaxonApiException
{
StringWriter sw = new StringWriter();
XdmNode source = null;
Processor proc = new Processor(false);
XsltCompiler comp = proc.newXsltCompiler();
XsltExecutable exp = comp.compile(new StreamSource(new File(xslFile)));
try
{
source = proc.newDocumentBuilder().build(new StreamSource(new ByteArrayInputStream(xmlData.getBytes("UTF-8"))));
}
catch (UnsupportedEncodingException e)
{
e.printStackTrace();
}
Serializer out = proc.newSerializer(sw);
out.setOutputProperty(Serializer.Property.INDENT, "yes");
XsltTransformer trans = exp.load();
trans.setInitialContextNode(source);
trans.setDestination(out);
trans.transform();
return sw.toString();
}