6.1. Obtaining Jakarta Commons Digester

Problem

You need to use Jakarta Commons Digester to quickly parse an XML document into a set of objects.

Solution

You must download the latest version of Commons Digester and place the Commons Digester JAR in your project’s classpath. Following the steps outlined in Recipe 1.1, download Commons Digester 1.5 instead of Commons Lang. Uncompress the distribution archive and place commons-digester.jar in your classpath. Commons Digester depends on Commons BeanUtils, Commons Logging, and Commons Collections. To download dependencies, see Recipe 3.2, Recipe 5.1, and Recipe 7.9.

Discussion

Commons Digester started as a part of Jakarta Struts, and it was moved to the Jakarta Commons project by way of the Commons Sandbox in early 2001. Digester is the mechanism Struts uses to read XML configuration; struts-config.xml is the main configuration point for Jakarta Struts, and it is converted to a set of objects using the Digester. The Digester’s most straightforward application is the mapping of an XML document to a set of Java objects, but, as shown in this chapter and Chapter 12, Digester can also be used to create a simple XML command language and search index. Digester is a shortcut for creating a SAX parser. Almost anything you can do with a SAX parser can be done with Jakarta Commons Digester.

If you have a Maven project that needs to use Commons Digester, add a dependency on Commons Digester 1.5 with the following section in project.xml:

<dependencies>
  <dependency>
    <id>commons-digester</id>
    <version>1.5</version>
  </dependency>
  ....other dependencies...
</dependencies>

See Also

For more information about Commons Digester, see the Commons Digester project page at http://jakarta.apache.org/commons/digester. For information about using the Digester to create a Lucene index, see Chapter 12.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.165.62