ParseTest3.java



import javax.xml.parsers.*;
import org.xml.sax.*;

/** SAX Parse Test for DTD Varidation */
public class ParseTest3 {

  /** Reader */
    private XMLReader reader = null;

  /** Constructor */
    public ParseTest3() {
        try {
            SAXParserFactory spf = SAXParserFactory.newInstance();
         // use name space
            spf.setNamespaceAware( true );
         // do validate
            spf.setValidating( true );
            SAXParser parser = spf.newSAXParser();
            reader = parser.getXMLReader();
            reader.setContentHandler( new MyContentHandler() );
            reader.setErrorHandler( new MyErrorHandler() );
        }
        catch( Exception e ) {
            System.err.println( e.toString() );
        }
    }

  /** main (start here) */
    public static void main( String[] argv ) {
        try {
            ParseTest3 test = new ParseTest3();
            InputSource source = new InputSource( argv[0] );
            test.reader.parse( source );
        }
        catch( Exception e ) {
            System.err.println( e.toString() );
        }
    }
}