Java tutorial
//package com.java2s; //License from project: Open Source License import javax.xml.transform.Templates; import java.io.File; import javax.xml.transform.TransformerFactory; import java.io.InputStream; import javax.xml.transform.stream.StreamSource; public class Main { public static Templates getTemplatesByName(File xslF) { Templates templates = null; TransformerFactory tfactory = TransformerFactory.newInstance(); tfactory.setAttribute("http://xml.apache.org/xalan/features/incremental", java.lang.Boolean.TRUE); InputStream is = null; try { StreamSource ss = new StreamSource(xslF); is = ss.getInputStream(); templates = tfactory.newTemplates(ss); if (is != null) { is.close(); is = null; } } catch (Exception e) { e.printStackTrace(); } finally { try { if (is != null) { is.close(); is = null; } } catch (Throwable t) { System.out.println(t); } } return templates; } }