Handler handler = new Handler(); reader.setErrorHandler(handler);
  void validateInput()    throws Exception  {    // Since we're going to use a SAX feature, the transformer must support     // input in the form of a SAXSource.    TransformerFactory tfactory = TransformerFactory.newInstance();    if(tfactory.getFeature(SAXSource.FEATURE))    {      // Standard way of creating an XMLReader in JAXP 1.1.      SAXParserFactory pfactory= SAXParserFactory.newInstance();      pfactory.setNamespaceAware(true); // Very important!      // Turn on validation.      pfactory.setValidating(true);      // Get an XMLReader.      XMLReader reader = pfactory.newSAXParser().getXMLReader();            // Standard way of creating a transformer from a URL.      Transformer t = tfactory.newTransformer(        new StreamSource("birds.xsl"));            // Specify a SAXSource that takes both an XMLReader and a URL.      SAXSource source = new SAXSource(reader,        new InputSource("birds.xml"));            try      {        // Transform to a file.        t.transform(source, new StreamResult("birds.out"));      }      catch(TransformerException te)      {        // The operation failed, so parse the entire XML input to get a complete listing of         // warnings and errors from the Handler inner class (see below).        Handler handler = new Handler();        reader.setErrorHandler(handler);        reader.parse("birds.xml");                // Note: If you are satisifed with reporting just the first exception, you can        // eliminate the preceding 3 statements and Handler inner class, and then report        // the first TransformerException as follows:        // System.out.println(te.getMessage());      }      System.out.println("Done!");    }    else      System.out.println("tfactory does not support SAX features!");  }