Code example for SchemaFactory

Methods: newSchema

0
     
    public void setValidating(boolean validate) {
        if (validate) {
            this.schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
            try { 
                this.schema = schemaFactory.newSchema(new StreamSource(getSchemaLocation()));
            } catch (org.xml.sax.SAXException e) {
                LOG.log(Level.SEVERE, "SCHEMA_FACTORY_EXCEPTION_MSG");
            } 
            try { 
                this.parserFactory.setSchema(this.schema);
            } catch (UnsupportedOperationException e) {
                LOG.log(Level.WARNING, "SAX_PARSER_NOT_SUPPORTED", e);
            } 
        } 
    } 
 
    public SAXParser getSAXParser() {
        return parser;
    } 
}