Table of contentsAppendices |
1.1 Overview of the DOM Core InterfacesOverview of the DOM Core InterfacesThe DOM Structure Model[top]The DOM Structure ModelThe DOM presents documents as a hierarchy of
The DOM also specifies a Finally, the interfaces Memory Management[top]Memory ManagementMost of the APIs defined by this specification are
interfaces rather than classes. That means that an
implementation need only expose methods with the defined names and
specified operation, not implement classes that correspond directly to
the interfaces. This allows the DOM APIs to be implemented as a thin
veneer on top of legacy applications with their own data structures, or
on top of newer applications with different class hierarchies. This
also means that ordinary constructors (in the Java or C++ sense) cannot
be used to create DOM objects, since the underlying objects to be
constructed may have little relationship to the DOM interfaces. The
conventional solution to this in object-oriented design is to define
factory methods that create instances of objects that
implement the various interfaces. Objects implementing some interface
"X" are created by a "createX()" method on the The Core DOM APIs are designed to be compatible with a wide range of languages, including both general-user scripting languages and the more challenging languages used mostly by professional programmers. Thus, the DOM APIs need to operate across a variety of memory management philosophies, from language bindings that do not expose memory management to the user at all, through those (notably Java) that provide explicit constructors but provide an automatic garbage collection mechanism to automatically reclaim unused memory, to those (especially C/C++) that generally require the programmer to explicitly allocate object memory, track where it is used, and explicitly free it for re-use. To ensure a consistent API across these platforms, the DOM does not address memory management issues at all, but instead leaves these for the implementation. Neither of the explicit language bindings defined by the DOM API (for ECMAScript and Java) require any memory management methods, but DOM bindings for other languages (especially C or C++) may require such support. These extensions will be the responsibility of those adapting the DOM API to a specific language, not the DOM Working Group. Naming Conventions[top]Naming ConventionsWhile it would be nice to have attribute and method names that are short, informative, internally consistent, and familiar to users of similar APIs, the names also should not clash with the names in legacy APIs supported by DOM implementations. Furthermore, both OMG IDL [OMGIDL] and ECMAScript [ECMAScript] have significant limitations in their ability to disambiguate names from different namespaces that make it difficult to avoid naming conflicts with short, familiar names. So, DOM names tend to be long and descriptive in order to be unique across all environments. The Working Group has also attempted to be internally consistent in its use of various terms, even though these may not be common distinctions in other APIs. For example, the DOM API uses the method name "remove" when the method changes the structural model, and the method name "delete" when the method gets rid of something inside the structure model. The thing that is deleted is not returned. The thing that is removed may be returned, when it makes sense to return it. Inheritance vs. Flattened Views of the API[top]Inheritance vs. Flattened Views of the APIThe DOM Core APIs present two somewhat
different sets of interfaces to an XML/HTML document: one presenting an
"object oriented" approach with a hierarchy of
inheritance, and a "simplified"
view that allows all manipulation to be done via the In practice, this means that there is a certain amount of redundancy
in the API. The Working Group considers
the "inheritance" approach the
primary view of the API, and the full set of functionality on
|