Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.StringWriter; import javax.xml.transform.Templates; import javax.xml.transform.Result; import javax.xml.transform.Transformer; import javax.xml.transform.stream.StreamSource; import java.io.Reader; public class Main { protected static Result internalTransformWithParams(Reader doc, Templates templates, Result r, boolean trace, String[] params) { StringWriter sw = new StringWriter(); try { Transformer transformer = templates.newTransformer(); if (params != null && params.length > 0) { for (int i = 0; i < params.length; i++) transformer.setParameter("param_" + i, params[i]); } transformer.transform(new StreamSource(doc), r); sw.close(); return r; } catch (Throwable th) { th.printStackTrace(); return r; } } }