Chapter 6. DOM Modules

Chapter 5 introduced and detailed the DOM API, and specifically what is called the DOM core. This is the portion of DOM that is most used, as it handles basic XML reading, as well as document creation. However, there are times when basic XML isn’t enough—whether you’re working with XML, or writing a document editor, or trying to serialize XML using the latest DOM APIs. In these specialized cases, you will often find a DOM module that can help.

I summarized the complete set of DOM specifications, including DOM modules, in Chapter 5. In this chapter, I’ll detail each module, and show you how you can use these modules in your applications.

Tip

Since DOM Level 3 is still new and largely unsupported, I’ve split coverage of these modules depending on the DOM Level they are based on. Most current parsers support at least a few of the DOM Level 2 modules, and a few will support beta versions of the DOM Level 3 modules.

Checking for Module Support

As a brief refresher (and so you’re not constantly flipping back to Chapter 5), Table 6-1 lists the DOM modules.

Table 6-1. Each module has a specific name used to query a parser for module support
SpecificationModule nameSummary of purpose
DOM Level 2 CoreXMLExtends the DOM Level 1 specification; deals with basic DOM structures like Element, Attr, Document, etc.
DOM Level 2 ViewsViewsProvides a model for scripts to dynamically update a DOM structure
DOM Level 2 EventsEventsDefines an event model for programs and scripts to use in ...

Get Java and XML, 3rd Edition 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.