Code example for DocumentBuilderFactory

Methods: getClasssetAttributesetNamespaceAwaresetValidating

0
        src = new StreamSource(schema.createInputStream());
        factory.setSchema(sf.newSchema(src));
    } 
 
    private static void setJaxp12Validating(DocumentBuilderFactory factory, Node schema) throws IOException {
        factory.setNamespaceAware(true);
        factory.setValidating(true);
        try { 
            factory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
        } catch (IllegalArgumentException x) {
            throw new RuntimeException(factory.getClass().getName() + ": parser does not support JAXP 1.2", x);
        } 
        factory.setAttribute(JAXP_SCHEMA_SOURCE, new ByteArrayInputStream(schema.readBytes()));
         
    } 
    public static DocumentBuilderFactory document() {
        return DocumentBuilderFactory.newInstance(); 
    } 
 
    //--