Java XML Document Create newDocument(boolean isNamespaceAware, boolean isValidating)

Here you can find the source of newDocument(boolean isNamespaceAware, boolean isValidating)

Description

__UNDOCUMENTED__

License

BSD License

Parameter

Parameter Description
isNamespaceAware __UNDOCUMENTED__
isValidating __UNDOCUMENTED__

Return

__UNDOCUMENTED__

Declaration

public static Document newDocument(boolean isNamespaceAware, boolean isValidating) 

Method Source Code


//package com.java2s;
/*//from   w  w  w  . j a v a  2  s  . com
 * Copyright (c) 2012. betterFORM Project - http://www.betterform.de
 * Licensed under the terms of BSD License
 */

import org.w3c.dom.*;

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

public class Main {
    /**
     * __UNDOCUMENTED__
     *
     * @param isNamespaceAware __UNDOCUMENTED__
     * @param isValidating     __UNDOCUMENTED__
     * @return __UNDOCUMENTED__
     */
    public static Document newDocument(boolean isNamespaceAware, boolean isValidating) {
        // !!! workaround to enable betterForm to run within WebLogic Server
        // Force JAXP to use xerces as the default JAXP parser doesn't work with BetterForm
        //
        //        String oldFactory = System.getProperty("javax.xml.parsers.DocumentBuilderFactory");
        //        System.setProperty("javax.xml.parsers.DocumentBuilderFactory","org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

        // restore to original factory
        //
        //        System.setProperty("javax.xml.parsers.DocumentBuilderFactory",oldFactory);
        // !!! end workaround
        factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(isNamespaceAware);
        factory.setValidating(isValidating);

        try {
            // Create builder.
            DocumentBuilder builder = factory.newDocumentBuilder();

            return builder.newDocument();
        } catch (ParserConfigurationException pce) {
            System.err.println(pce.toString());
        }

        return null;
    }
}

Related

  1. newDocument()
  2. newDocument()
  3. newDocument()
  4. newDocument()
  5. newDocument()
  6. newDocument(File file)
  7. newDocument(String namespaceURI, String qualifiedName)
  8. newDocument(String rootName)
  9. newXMLDocument()