Given a scenario:
I have my own system’s object structure. Now there are more than one XML sources I have to map to my java classes. And there is no need to convert Java object back into XML.
What’s your suggestion for me to use Digester or JAXB? Currently I lean to use Digester, because I can specify XML path for each XML source to the same object method call, and Digester seems to be easier to maintain. Although JAXB has good design to marshal/unmarshal java and XML, but I think it is too complicated, xml schema is needed for each xml-java mapping, right?
I think both Digester or JAXB has their mission to fit different usage scenario, so need your advice to help me decide one of them. Thanks a lot.
An advantage of JAXB is that it is a spec (JSR-222) with multiple implementations: Metro, EclipseLink MOXy, JaxMe. This avoids the problem of vendor lock in.
XPath Based Mapping
The EclipseLink JAXB (MOXy) has an extension to support XPath based mapping (I’m the tech lead).
Multiple XML Sources
To apply multiple XML representations to an object model you can leverage MOXy’s XML metadata. This is another extension to the JAXB standard. An example file looks like:
For more information: