Code example for SAXParseException

Methods: getMessage

0
        Validator validator = LayoutDevicesXsd.getValidator(null);
        try { 
            validator.validate(source);
        } catch (SAXParseException e) {
            // We expect a parse expression referring to this grammar rule 
            assertRegex(regexp, e.getMessage());
            return; 
        } 
        // If we get here, the validator has not failed as we expected it to. 
        fail();
    } 
 
    public void checkSuccess(String document) throws Exception {
        Source source = new StreamSource(new StringReader(document));
 
        CaptureErrorHandler handler = new CaptureErrorHandler();
        Validator validator = LayoutDevicesXsd.getValidator(null);
        validator.validate(source);
        handler.verify();
    }