Package br.net.woodstock.rockframework.xml.dom

Source Code of br.net.woodstock.rockframework.xml.dom.SunXmlWriter

/*
* This file is part of rockframework.
*
* rockframework is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* rockframework is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>;.
*/
package br.net.woodstock.rockframework.xml.dom;

import java.io.IOException;
import java.io.Writer;
import java.nio.charset.Charset;

import org.w3c.dom.Document;

import com.sun.org.apache.xml.internal.serialize.OutputFormat;
import com.sun.org.apache.xml.internal.serialize.XMLSerializer;

class SunXmlWriter extends XmlWriter {

  public SunXmlWriter() {
    super();
  }

  @Override
  public void write(final Document document, final Writer writer, final Charset charset) throws IOException {
    OutputFormat format = new OutputFormat(document, charset.name(), true);
    format.setIndent(1);
    format.setIndenting(true);
    format.setLineWidth(0);

    XMLSerializer serializer = new XMLSerializer(writer, format);
    serializer.asDOMSerializer();
    serializer.serialize(document);
  }

}
TOP

Related Classes of br.net.woodstock.rockframework.xml.dom.SunXmlWriter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.