Summary


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 by JAXP, by vendor-specific classes, or by the DOMImplementationRegistry class in DOM3.

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 subinterface of Node and has all of the methods of that interface discussed in Chapter 9. This is crucial for adding content to documents and removing content from documents, especially at the top level outside the root element.



Processing XML with Java. A Guide to SAX, DOM, JDOM, JAXP, and TrAX
Processing XML with Javaв„ў: A Guide to SAX, DOM, JDOM, JAXP, and TrAX
ISBN: 0201771861
EAN: 2147483647
Year: 2001
Pages: 191

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net