FileDocCategorySizeDatePackage
Skeleton.javaAPI DocExample1551Fri Feb 01 12:50:18 GMT 2002None

Skeleton

public class Skeleton extends Object
SAX2 Application Skeleton

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] argv)

        XMLReader       producer;
        DefaultHandler  consumer;

        // Get an instance of the default XML parser class
        try {
            producer = XMLReaderFactory.createXMLReader ();
        } catch (SAXException e) {
            System.err.println (
                  "Can't get parser, check configuration: "
                + e.getMessage ());
            return;
        }

	// set up the consumer
	try {

	    // Get a consumer for all the parser events
	    consumer = new DefaultHandler ();

	    // Connect the most important standard handler
	    producer.setContentHandler (consumer);

	    // Arrange error handling
	    producer.setErrorHandler (consumer);
	} catch (Exception e) {
	    // consumer setup can uncover errors,
	    // though this simple one shouldn't
	    System.err.println (
	          "Can't set up consumers:"
                + e.getMessage ());
            return;
	}

        // Do the parse!
        try {
            producer.parse (argv [0]);
        } catch (IOException e) {
            System.err.println ("I/O error: ");
	    e.printStackTrace ();
        } catch (SAXException e) {
            System.err.println ("Parsing error: ");
	    e.printStackTrace ();
        }