Java XML DocumentBuilder Create getDocumentBuilder()

Here you can find the source of getDocumentBuilder()

Description

get Document Builder

License

Open Source License

Declaration

private static DocumentBuilder getDocumentBuilder() throws ParserConfigurationException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (C) 2005 - 2014 TIBCO Software Inc. All rights reserved. http://www.jaspersoft.com.
 * //from   w  w  w .  j  a  v  a 2 s  .  co m
 * Unless you have purchased a commercial license agreement from Jaspersoft, the following license terms apply:
 * 
 * This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
 ******************************************************************************/

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

public class Main {
    private static DocumentBuilder db;

    private static DocumentBuilder getDocumentBuilder() throws ParserConfigurationException {
        if (db == null) {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            dbf.setValidating(false);
            dbf.setIgnoringComments(true);
            dbf.setFeature("http://xml.org/sax/features/namespaces", false);
            dbf.setFeature("http://xml.org/sax/features/validation", false);
            dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
            dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);

            db = dbf.newDocumentBuilder();
        }
        return db;
    }
}

Related

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