Chapter 10. dom4j

Like JDOM, which was explored in the last chapter, dom4j is designed to be a Java-specific alternative to DOM—a document object model that is targeted only at Java (thus the repeated use of the letter J) and isn’t constrained by language neutrality in the way DOM is. Since dom4j and JDOM share this common goal, portions of the APIs look similar. However, the two APIs do differ on a key design principal in that dom4j is built around a set of core interfaces, whereas JDOM is class-orientated. What this means in practice is that there are various implementations of the core dom4j interfaces that provide different functionality. Through this, dom4j’s behavior can be tuned to match the needs of your application.

Also like JDOM, dom4j is an open source project with a vibrant user community that you can join to receive assistance with the API and contribute to the future of dom4j. Full details on dom4j can be found at http://www.dom4j.org.

Overview

With that brief introduction to dom4j, let us begin by looking at the interfaces and classes that make up dom4j. We’ll start with the core interfaces and then examine some of the special features those interfaces have that set dom4j apart from other similar APIs.

Core dom4j

As I mentioned above, dom4j is built around a set of core interfaces. These interfaces describe the structure and content of an XML document. Figure 10-1 contains a UML model of these core interfaces.

Figure 10-1. UML model of dom4j core interfaces

As you can ...

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.