The Document Interface as an Abstract Factory
The Document interface, summarized in Example 10.4, serves two purposes in DOM:
As an abstract factory, it creates instances of other nodes for that document.
It is the representation of the document node.
Example 10.4. The Document Interface
package org.w3c.dom; public interface Document extends Node { public Element createElement(String tagName) throws DOMException; public Element createElementNS(String namespaceURI, String qualifiedName) throws DOMException; public Text createTextNode(String data); public Comment createComment(String data); public CDATASection createCDATASection(String data) throws DOMException; public ProcessingInstruction createProcessingInstruction( String target, String data) ... |
Get Processing XML with Java™: A Guide to SAX, DOM, JDOM, JAXP, and TrAX now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.