Java XML DocumentBuilder Create getDocumentBuilderFactory()

Here you can find the source of getDocumentBuilderFactory()

Description

get Document Builder Factory

License

Open Source License

Declaration

public static synchronized DocumentBuilderFactory getDocumentBuilderFactory() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.xml.parsers.DocumentBuilderFactory;

public class Main {
    public static final String JAVA_INTERNAL_DBF_CLASS = "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl";
    public static final String DBF_SYSTEM_PROPERTY = "javax.xml.parsers.DocumentBuilderFactory";

    public static synchronized DocumentBuilderFactory getDocumentBuilderFactory() {
        String oldDbfImpl = System.getProperty(DBF_SYSTEM_PROPERTY);
        System.setProperty(DBF_SYSTEM_PROPERTY, JAVA_INTERNAL_DBF_CLASS);
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        if (oldDbfImpl != null) {
            System.setProperty(DBF_SYSTEM_PROPERTY, oldDbfImpl);
        } else {//from  www .  ja  v a2  s .  c om
            System.getProperties().remove(DBF_SYSTEM_PROPERTY);
        }
        return dbf;
    }
}

Related

  1. getDocumentBuilder()
  2. getDocumentBuilder()
  3. getDocumentBuilder(boolean NamespaceAwareness)
  4. getDocumentBuilder(boolean secure)
  5. getDocumentBuilderFactory()
  6. getDocumentBuilderFactory()
  7. getDocumentBuilderFactory()
  8. getDocumentBuilderFactory()
  9. getDocumentBuilderFactory(boolean isNamespaceAware)