Code example for DocumentBuilder

Methods: parse, setErrorHandler

0
            //setting this property should throw IllegalArgumentException 
            dbf.setAttribute(
            "http://java.sun.com/xml/jaxp/properties/schemaSource", 
            "tests/jaxp/data/personal-schema.xsd"); 
            DocumentBuilder docBuilder = dbf.newDocumentBuilder();
            docBuilder.setErrorHandler(this);
            Document document = docBuilder.parse(
            "tests/jaxp/data/personal-schema.xml"); 
        } catch (IllegalArgumentException e) {
            System.out.println(" JAXPSpecTest.testSchemaSourceDOM Passed");
        } 
         
    } 
     
     
    /** Handles Warnings 
     * @param ex 
     * @throws SAXException 
     */ 
    public void warning(SAXParseException ex) throws SAXException {
        printError("Warning", ex);