cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ivelin Ivanov" <>
Subject Re: Bean generator
Date Fri, 12 Apr 2002 13:33:39 GMT

Nick, to answer your question,
I'll just forward a discussion I just had with James Strachan.

See below:

----- Original Message -----
From: "Nick Airey" <>
To: <>
Sent: Friday, April 12, 2002 4:08 AM
Subject: Bean generator

> Hello everyone,
> I think it would be useful to have a "BeanGenerator", which basically
> generates SAX events based on a java bean.
> I already have written several of these, customized according to various
> java bean structures, but I see I am going to need more of them, so it
> would be cool to replace all of these generators with a single generator
> which uses bean introspection to generate SAX events.
> In my case, the beans in question are value objects returned from EJB
> middleware, and cocoon is doing all the presentation layer processing.
> My question is: does something like this exist already? I suspect not.
> If not, my second question is: does anyone know a good (open) framework
> for converting beans to SAX events. I have been doing some research, and
> have come across several projects:
> Betwixt
> (
> Looks promising, but doesn't (yet) have a SAX writer.
> Domify:
> (
> Hammer:
> (
> Stars in the WROX "Java XML" book, published 2001, chapter 6.
> Can anyone comment on which would be a good way to go. Of course, if
> this is considered to be generally useful, I would be happy to donate
> the code for the resulting generator to the cocoon project.
> Nick.

----- Original Message -----
From: "James Strachan" <>
To: "Jakarta Commons Developers List" <>
Sent: Monday, April 08, 2002 10:32 PM
Subject: Re: [Question] Betwix & JAXB

> Hi Ivelin
> From: "Ivelin Ivanov" <>
> > Is there a rundown available on the reasons why Betwix is developing in
> > paralel with JAXB?
> Good question :-)
> > I've used Castor for quite some time and have been happy with its
> > performance.
> JAXB takes the approach that a DTD (and one day an XML schema) is used to
> generate beans that can parse/output the XML, then you can derive from
> to add behaviour.
> Betwixt takes a different approach, that starting with any bean, it
> has a default XML representation; then betwixt can be customized with just
> the differences you want (moving elements around, adding arbitrary extra
> nestings, renaming elements/attributes etc). Then betwixt can parse XML
> (using Digester, it essentially defaults digester rules) or output XML
> straight away, then customize to make it esthetically nicer XML later.
> On the list of things planned are SAX reader/writers and a DOM
> implementation using betwixt's mappings, then XSLT can be used on beans
> (like the Maven project does). Also I should finally get around to using
> Betwixt to add a bean Navigator to the Jaxen XPath engine. Betwixt
> essentially mirrors the Introspector / BeanInfo classes from java.beans
> for mapping information of beans to XML, so there's an XMLIntrospector and
> XMLBeanInfo etc.
> Both the JAXB & betwixt approaches are equally valid; JAXB is useful if
> want some beans generated from some kind of XML 'schema', betwixt is
> if you already have the beans and want to customize what the XML looks
> or to automatically default digester rules for you, then maybe customize
> things later.
> So if you're starting from beans and want nice XML then betwixt is a good
> tool for the job; if you're starting with a DTD and want to write some
> beans, then look at JAXB.
> Castor is kinda in the middle between them with a bit more complexity
> in for good measure but its got some good stuff in there. Though I always
> get the impression Castor is trying to do too much together at the same
> rather than just doing one thing well, but maybe thats just me. I can't
> think of the phrase 'jack of all trades and master of none'. e.g. Castor
> JDO-like without being compliant, its kind of an O/R mapping tool, its a
> reasonable O/XML mapping tool and a kinda OQL engine all thrown in
> An impressive body of work though.
> As an aside, betwixt focusses on the mapping metadata of how beans should
> map to XML, so betwixt could maybe be used to generate Castor java <-> XML
> bindings - though I'm not sure why you'd want to do that ;-)
> > Apache Axis build their own JavaBean-XML mapping and Betwix is yet
> > development in the area.
> Its on my list to investigate using Betwixt in Axis. SOAP supports various
> different encodings, 1 of which (usually called the 'soap encoding') is a
> well defined mapping of SOAP to java objects, so Axis probably implements
> that spec.
> However for some of the other encodings (such as none where you just get
> XML), then maybe betwixt could be used to map a SOAP schema to some
> implementation beans. i.e. to have a flexible, customizable mapping.
> I'd certainly like try out a Betwixt based serializer/deserializer for
> and see if it works neatly.
> James
> _________________________________________________________
> Do You Yahoo!?
> Get your free address at
> --
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, email:

View raw message