Java XML Transform transform(Source xmlSource, Templates template, Result result, Map parameters)

Here you can find the source of transform(Source xmlSource, Templates template, Result result, Map parameters)

Description

Transform the XML to result.

License

Apache License

Parameter

Parameter Description
xmlSource defines the input source
template defines the transformer source.
result defines the result.
parameters defines the list of parameter.

Exception

Parameter Description
IOException the IO error occur.
TransformerException the transformation error occur.

Declaration

public static void transform(Source xmlSource, Templates template, Result result,
        Map<String, String> parameters) throws IOException, TransformerException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.IOException;

import java.util.Map;

import javax.xml.transform.OutputKeys;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Templates;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;

public class Main {
    /**/* ww w .  j  ava 2  s  .com*/
     * Transform the XML to result.
     *
     * @param xmlSource defines the input source
     * @param template defines the transformer source.
     * @param result defines the result.
     * @param parameters defines the list of parameter.
     * @throws IOException the IO error occur.
     * @throws TransformerException the transformation error occur.
     */
    public static void transform(Source xmlSource, Templates template, Result result,
            Map<String, String> parameters) throws IOException, TransformerException {
        Transformer transformer = template.newTransformer();
        if (parameters != null) {
            for (String key : parameters.keySet()) {
                transformer.setParameter(key, parameters.get(key));
            }
        }
        transformer.setOutputProperty(OutputKeys.INDENT, "no");
        transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
        transformer.transform(xmlSource, result);
    }
}

Related

  1. transform(Source source, Result res)
  2. transform(Source source, Result result)
  3. transform(Source source, Source stylesheet, Map params, Properties outputProperties)
  4. transform(Source source, Templates cachedXSLT)
  5. transform(Source xmlSource, Result outputTarget)
  6. transform(Source xsl, Source xml, Result result)
  7. transform(String xmlInputFile, String xsltInputFile, OutputStream outputStream)
  8. transform(String xmlInURI, String xslInURI)
  9. transform(String xmlsource, File xsltfile)