geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Strachan <james_strac...@yahoo.co.uk>
Subject Re: [XML Parsing]
Date Tue, 02 Sep 2003 12:47:59 GMT

On Monday, September 1, 2003, at 02:28  pm, Aaron Mulder wrote:

> On Mon, 1 Sep 2003, James Strachan wrote:
>> If we go the POJO route (as described in the [vote] XML Parsing  
>> thread)
>> then using Betwixt (which uses Digester) is my preferred route. We can
>> then let Xerces take care of the XSD validation.
>
> 	I'm new to Betwixt, but it looks like we have two options.  One is
> to define a .betwixt file for every POJO

No thats only if you want to customize things on a per class basis


> , and the other is to have one big
> class which sets up all the Betrixt mappings in code.

No. By default Betwixt will do this all for you using sensible defaults.


> I was hoping for
> the middle solutions -- one mapping file listing all of the mappings.
> Which path do you recommend?

Out of the box Betwixt can handle the marshalling for you. You can  
instantiate your own XMLIntrospector and customize it to how you want  
the XML to look (e.g. for J2EE its to use elements rather than  
attributes and so forth). Then just go right ahead and marshall.

A good example to see it in action is commons-sql...

http://jakarta.apache.org/commons/sandbox/sql/index.html

here are the 2 simple classes to wrap up the use of betwixt for  
marshalling in / out of XML...

http://jakarta.apache.org/commons/sandbox/sql/apidocs/org/apache/ 
commons/sql/io/package-summary.html

then here are the POJOs...

http://jakarta.apache.org/commons/sandbox/sql/apidocs/org/apache/ 
commons/sql/model/package-summary.html

Doing something similar should be pretty easy and save us having to  
hand-craft digester rules.

James
-------
http://radio.weblogs.com/0112098/


Mime
View raw message