cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tony Edwards <>
Subject RE: Beans as input for cocoon
Date Wed, 16 Jul 2003 23:46:17 GMT


Its in the cocoon-scratchpad.jar.
You initialise it thus:
<map:transformer name="castor" logger="sitemap.transformer.castor"

My pipeline segment for the castor bit looks like this:

		<map:match pattern="lodgement">
			<!-- Instanciate the object and add it the session
			<map:act type="xsp-action"
				<!-- This part is called when the action
executes <action:set-success/> -->
				<!-- Do the castor:InsertBean stuff from
this xml file -->
				<map:generate src="xml/lodge.xml"/>

				<map:transform type="castor"/>	
				<map:transform src="xsl/object2enf.xsl"/>
				<map:serialize type="xml"/>
			<!-- This part is called when the action executes
			<map:generate type="serverpages" src="error.xsp"/>

I'm using an xsp-action which loads up the bean, connects to the database
and populates all its fields:
	<!-- snip -->
	LodgementTransaction lodge = new

	<!-- snip -->

Finally, I add the bean to the session:

	session.setAttribute("lodgement", lodge);

The lodge.xml tell castor which scope to look for the bean, in this case

<?xml version="1.0"?>
<civica xmlns:castor="">	
	<castor:InsertBean name="lodgement" scope="session"/> 	

I then run the output xml stream through a few xsl 'filters' to extract only
the data that I need (its a big bean :)).
the test-mapping.xml mentioned in the map:transformer section is straight
from the example. If the mapping file can't find an element mentioned in the
mapping file, it will use the default which is provided by the castor
If you spend a little time playing around with this, you'll begin to
appreciate its huge potential.



-----Original Message-----
From: Uwe Gerger []
Sent: Wednesday, 16 July 2003 6:22 PM
Subject: Re: Beans as input for cocoon

where can I find the castor transformer? I use cocoon 2.0.4. but I
couldn't find it neither in cocoon 2.1 documentation!?


> schrieb:
> I'm using the Castor transformer to convert a large, nasty bean into
> xml and then into HTML/PDF.
> It works really well, seems fast (the slowest bit is the bean
> accessing the database to get its data) and best of all it manages to
> convert all ArrayLists and other complex types.
> I initially use an XSP action to instantiate the bean and connect to
> the datasource and populate the bean, then I pass this though the
> Castor Transformer. I use the same mapping file that comes with the
> example because the bean is so huge it would take too long to even
> come up with a mapping file but Castor ignores all mappings it can't
> find or aren't there and outputs elements based on the Bean field
> names. Excellent!
> Tony
> -----Original Message-----
> From: Alexander Schatten []
> Sent: Wednesday, 16 July 2003 1:29 AM
> To:
> Subject: Re: Beans as input for cocoon
> Uwe Gerger wrote:
> >Hello,
> >we have some Java-beans wich contains the data we wish to transform
> with
> >cocoon into PDF. Is there a way how we can get the data from the bean
> >into cocoon? Maybe there is a special bean-transformer or something
> like
> >this?
> >
> >
> >
> Hm, a BeanGenerator could be a nice idea? but where would this bean
> get
> the data from? it would be initialized by the generator, so is
> "empty";
> off course you could read a file or something in the bean constructor
> or
> access a database; but for both things there seem to be more elegant
> options.
> in fact you can access beans from within XSP scripts or actions, maybe
> this is a convenient solution.
> alex
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Uwe Gerger                                _/_/_/   _/    _/  _/    _/
BMW AG, TG-53 IT-Technologie             _/   _/  _/_/_/_/  _/    _/
80788 Muenchen                          _/_/_/   _/ _/ _/  _/ _/ _/
Tel: +49 89 382 35687                  _/   _/  _/    _/  _/_/_/_/
Fax: +49 89 382 49040                 _/_/_/   _/    _/  _/    _/

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

View raw message