question: public static Document createDocument ( boolean isSecureProcessing ) { try { DocumentBuilderFactory dfactory = DocumentBuilderFactory . newInstance ( ) ; dfactory . setNamespaceAware ( true ) ; DocumentBuilder docBuilder = dfactory . newDocumentBuilder ( ) ; Document outNode = docBuilder . newDocument ( ) ; return outNode ; } catch ( ParserConfigurationException pce ) { throw new RuntimeException ( XMLMessages . createXMLMessage ( XMLErrorResources . ER_CREATEDOCUMENT_NOT_SUPPORTED , null ) ) ; } }
target:  DOM Level 1 did not have a standard mechanism for creating a new Document object. This function provides a DOM-implementation-independent abstraction for that for that concept. It's typically used when  outputting a new DOM as the result of an operation. <p> TODO: This isn't directly compatable with DOM Level 2.  The Level 2 createDocument call also creates the root  element, and thus requires that you know what that element will be before creating the Document. We should think about whether we want to change this code, and the callers, so we can use the DOM's own  method. (It's also possible that DOM Level 3 may relax this sequence, but you may give up some intelligence in the DOM by doing so; the intent was that knowing the document type and root element might let the DOM automatically switch to a specialized subclass for particular kinds of documents.)