Java XML Transform Usage getTemplatesByName(File xslF)

Here you can find the source of getTemplatesByName(File xslF)

Description

get Templates By Name

License

Open Source License

Declaration

public static Templates getTemplatesByName(File xslF) 

Method Source Code

//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;/*  w ww .  j  a v a  2  s .c  o m*/
        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;
    }
}

Related

  1. getNormalizedReader(Reader reader)
  2. getSaxSource(File newFile, SAXParserFactory spf)
  3. getSchema(InputStream... inputs)
  4. getSourceFromEndpointReference(EndpointReference epr)
  5. getStreamSources(File[] stylesheets)
  6. getWSAAddress(W3CEndpointReference ref)
  7. getXMLCalendar(Date date)
  8. getXmlEventWriter(Result r)
  9. longToGregorian(long date)