19.2 Structure of the DOM Core   The DOM Core interfaces provide generic access to all supported document content types. The DOM also defines a set of HTML-specific interfaces that expose specific document structures, such as tables, paragraphs, and  img  elements, directly. Besides using these specialized interfaces, you can access the same information using the generic interfaces defined in the core.    Since XML is designed as a venue for creating new, unique, structured markup languages, standards bodies cannot define application-specific interfaces in advance. Instead, the DOM Core interfaces are provided to manipulate document elements in a completely application-independent manner.    The DOM Core is further segregated into the Fundamental and Extended Interfaces. The Fundamental Interfaces are relevant to both XML and HTML documents, whereas the Extended Interfaces deal with XML-only document structures, such as entity declarations and processing instructions. All DOM Core interfaces are derived from the  Node  interface, which provides a generic set of methods for accessing a document or document fragment's tree structure and content.    19.2.1 Generic Versus Specific DOM Interfaces   To simplify different types of document processing and enable efficient implementation of DOM by some programming languages, there are actually two distinct methods for accessing a document tree from within the DOM Core: through the generic  Node  interface and through specific interfaces for each node type. Although there are several distinct types of markup that may appear within an XML document (elements, attributes, processing instructions, and so on), the relationships between these different document features can be expressed as a typical hierarchical tree structure. Elements are linked to both their predecessors and successors, as well as their parent and child nodes. Although there are many different types of nodes, the basic parent, child, and sibling relationships are common to everything in an XML document.    The generic  Node  interface captures the minimal set of attributes and methods that are required to express this tree structure. A given  Node  contains all of the tree pointers required to locate its parent node, child nodes, and siblings. The next section describes the  Node  interface in detail.    In addition to the generic  Node  interface, the DOM also defines a set of XML-specific interfaces that represent distinct document features, such as elements, attributes, processing instructions, and so on. All of the specific interfaces are derived from the generic  Node  interface, which means that a particular application can switch methods for accessing data within a DOM tree at will by casting between the generic  Node  interface and the actual specific object type it represents. Section 19.4 later in this chapter discusses the specific interfaces and their relationship to the generic  Node  interface.    |