Listing 1. The main application
import org.xml.sax.helpers.XMLReaderFactory;
import org.xml.sax.XMLReader;
import org.xml.sax.SAXException;
import org.xml.sax.InputSource;
import java.io.IOException;
public class MainSaxApp {
public static void main (String[] args){
try {
String parserClass = "org.apache.crimson.parser.XMLReaderImpl";
XMLReader reader = XMLReaderFactory.createXMLReader(parserClass);
WeblogHandler content = new WeblogHandler();
ErrorProcessor errors = new ErrorProcessor();
reader.setContentHandler(content);
reader.setErrorHandler(errors);
InputSource file = new InputSource("changes.xml");
reader.parse(file);
} catch (IOException ioe) {
System.out.println("IO Exception: "+ioe.getMessage());
} catch (SAXException se) {
System.out.println(se.getMessage());
}
}
}
|
