Java XML Transform internalTransformWithParams(Reader doc, Templates templates, Result r, boolean trace, String[] params)

Here you can find the source of internalTransformWithParams(Reader doc, Templates templates, Result r, boolean trace, String[] params)

Description

internal Transform With Params

License

Open Source License

Declaration

protected static Result internalTransformWithParams(Reader doc, Templates templates, Result r, boolean trace,
            String[] params) 

Method Source Code

//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) {//from  w  w w .ja va 2 s  .  co m
        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;
        }

    }
}

Related

  1. getXmlSecureTransform()
  2. getXmlSecureTransformerFactory()
  3. getXmlTransformer()
  4. getXMLTransformer()
  5. getXsltTransformer(File xsltFile)
  6. newTransformer()
  7. newTransformer()
  8. newTransformer()
  9. newTransformer(boolean indented)