Java XML Document Transform transform(Document doc, Result result)

Here you can find the source of transform(Document doc, Result result)

Description

transform

License

Open Source License

Declaration

private static void transform(Document doc, Result result) throws Exception 

Method Source Code

//package com.java2s;

import javax.xml.transform.OutputKeys;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;

import org.w3c.dom.Document;

public class Main {
    private static void transform(Document doc, Result result) throws Exception {
        try {//from   www .j  av a  2 s  . c o  m
            // Prepare the DOM document for writing
            Source source = new DOMSource(doc);

            // Write the DOM document to the file
            Transformer xformer = TransformerFactory.newInstance().newTransformer();
            xformer.setOutputProperty(OutputKeys.INDENT, "yes");
            xformer.transform(source, result);
        } catch (TransformerConfigurationException e) {
            e.printStackTrace();
            throw e;
        } catch (TransformerException e) {
            e.printStackTrace();
            throw e;
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }

    }
}

Related

  1. transfer(Document doc, String filepath)
  2. transform(Document doc, Result result)
  3. transform(Document doc, StreamSource xslInput, String systemid)
  4. transform(Document document, Properties outputProperties, StreamResult streamResult)
  5. transform(Document dom, Document xslt)
  6. transform(final Document document, final StreamResult streamResult, final boolean xmlDeclaration)