DOM is designed around the abstract factory design pattern. The DOMImplementation interface is the abstract factory that creates implementation-specific instances of the Document and DocumentType interfaces. A vendor specific DOMImplementation object can be retrieved either by JAXP, by vendor-specific classes, or by the DOMImplementationRegistry class in DOM Level 3.
The Document interface is in turn an abstract factory that creates implementation-specific instances of Element, Text, Comment, Attr, ProcessingInstruction, EntityReference, CDATASection, and DocumentFragment. Each instance of these classes can only be part of the Document that created it. However, the Document interface also has an importNode() method that copies a node from one document to another.
The Document interface is also DOM’s representation of the root node of the tree. It provides methods to get the implementation that created the Document object, get the root element of the document, get the DOCTYPE of the document, import nodes into the document from other documents, and find elements by name, namespace, and ID. This last capability is often enough for many simple search applications.
Finally, don’t forget that Document is a sub-interface of Node and has all the methods of that interface that were discussed in the last chapter. This is crucial for adding content to and removing content from documents, especially at the top level outside the root element.
|Copyright 2001, 2002 Elliotte Rusty Haroldfirstname.lastname@example.org||Last Modified December 31, 2001|
|Up To Cafe con Leche|