commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: [Digester] Newbie question
Date Mon, 28 Apr 2003 16:17:53 GMT

On Mon, 28 Apr 2003, Frank Meijer wrote:

> Date: Mon, 28 Apr 2003 11:20:39 -0400
> From: Frank Meijer <>
> Reply-To: Jakarta Commons Users List <>
> To: Jakarta Commons Users List <>
> Subject: [Digester] Newbie question
> How is Digester different from JAXB?  What would cause me to choose one over
> the other?

Digester preceeded JAXB by a couple of years, and is somewhat
narrower+different in scope.

* Digester focuses only on reading XML (and a common use case is
  creating corresponding beans, but that's not the only one),
  while JAXB offers bidirectional support (java->XML as well).

* Digester does not presuppose that you're going to process the
  entire XML document -- you define matching rules to pull out
  what you are interested in, and ignore the rest.  JAXB wants a
  bean hierarchy to match the entire document.

* Digester can be used to pull data out of any well-formed
  XML document, at the cost of having to create your own bean
  classes; JAXB has limits but will auto-generate bean classes
  for your.

* Digester leverages the underlying BeanUtils capabilities to
  set bean properties via reflection.  As a result, for example,
  it supports open-ended sets of attributes that can all be set
  into the corresponding bean properties with SetPropertiesRule.

Digester was originally created for processing configuration files like
server.xml in Tomcat, and struts-config.xml in Struts.  It's features and
functionality are biased towards what you need for that use case.  (Note
that a companion Commons package, betwixt, does some of the Java->XML
stuff you might want).

JAXB was originally created as a data binding solution that can map
between XML and Java objects in a general way, and (most especially) in a
bidirectional way.

Which one to use depends, of course, on your app requirements.

> Thanks,
> ...Frank


View raw message