package uk.ac.man.cs.img.xml.merge;




import java.io.StringWriter;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.xml.serialize.OutputFormat;
import org.apache.xml.serialize.XMLSerializer;
import org.w3c.dom.Node;
import org.w3c.dom.Document;



/**
 * Debug.java
 *
 *
 * Created: Thu Sep 11 12:26:01 2003
 *
 * @author <a href="mailto:p.lord@russet.org.uk">Phillip Lord</a>
 * @version 1.0
 */
public class Debug 
{
    public static void printNode( Node node ) 
    {   
        try{
            // set up some parsers for later use
            DocumentBuilderFactory builderFactory = new org.apache.xerces.jaxp.DocumentBuilderFactoryImpl();
            DocumentBuilder builder = builderFactory.newDocumentBuilder();
            
            Document output = builder.newDocument();
            output.appendChild
                ( output.importNode( node, true ) );
            
            // Output the document
            OutputFormat    format  = new OutputFormat( output, null, true );
            StringWriter  stringOut = new StringWriter();
            XMLSerializer    serial = new XMLSerializer( stringOut, format );
            serial.asDOMSerializer();
            serial.serialize( output.getDocumentElement() );
            
            System.out.println( stringOut.toString() );
        }
        catch( Exception exp ){
            exp.printStackTrace();
        }
        
    }
    
} // Debug
