// copyright => http://www.jxml.com/mdsax/License.txt

package com.jxml.quick;
import org.xml.sax.*;

public class QTraceFactory extends QFilterFactory
{
    public static QContext debug(QDoc doc)
	throws SAXException
    {
	QFilterFactory old=(QFilterFactory)Quick.getRoot(doc);
	QSeqFactory wrapper=new QSeqFactory();
	QTraceFactory t=new QTraceFactory();
	t.addToFactory(wrapper);
	old.addToFactory(wrapper);
	QDoc wrapperDoc=com.jxml.quick.engine.QCMLBindings.createDoc(wrapper);
	return com.jxml.quick.engine.QCMLBindings.createContext(wrapperDoc);
    }

    protected QFilter newFilter()
	throws QE
    {
	return new QTrace();
    }

    public class QTrace extends QFilter
    {
	public QTrace()
	    throws QE
	{
	}

	public void startDocument()
	    throws QPE
	{
	    System.out.println("start Document");
	}
	
	public void endDocument()
	    throws QPE
	{
	    System.out.println("end Document");
	}
	
	public void startElement(String name)
	    throws QPE
	{
	    System.out.println("start Element name="+name);
	}
	
	public void endElement(String name, String text, boolean cdata)
	    throws QPE
	{
	    System.out.println("end Element name="+name+" text=\""+text+"\"");
	}
    }
}
