/*
 * Created on 28 juin 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package org.injac.oai.util;
import java.io.ByteArrayOutputStream;

import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerConfigurationException;
import org.w3c.dom.*;
import javax.xml.transform.dom.DOMSource; 

import javax.xml.transform.stream.StreamResult;
/**
 * @author shoam
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class IdentityTransformer {
	
	private static TransformerFactory tFactory = TransformerFactory.newInstance();
	
	public static String TransformToString(Document doc)
	{
		String result="";
		try
		{
			Transformer transformer = tFactory.newTransformer();
			transformer.setOutputProperty("indent", "yes");
			transformer.setOutputProperty("encoding", "iso-8859-1");
			transformer.setOutputProperty("omit-xml-declaration", "yes");
			DOMSource source = new DOMSource(doc);
			ByteArrayOutputStream OS = new ByteArrayOutputStream();
			StreamResult resultSt = new StreamResult(OS);
			transformer.transform(source, resultSt);
			result = OS.toString();
		}catch(Exception exp)
		{
			
		}
		return result;
	}

}
