Here you can find the source of transform(Source xmlSource, Templates template, Result result, Map
Parameter | Description |
---|---|
xmlSource | defines the input source |
template | defines the transformer source. |
result | defines the result. |
parameters | defines the list of parameter. |
Parameter | Description |
---|---|
IOException | the IO error occur. |
TransformerException | the transformation error occur. |
public static void transform(Source xmlSource, Templates template, Result result, Map<String, String> parameters) throws IOException, TransformerException
//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); } }