cocoon-users mailing list archives

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

Uwe,

Its in the cocoon-scratchpad.jar.
You initialise it thus:
<map:transformer name="castor" logger="sitemap.transformer.castor"
src="org.apache.cocoon.transformation.CastorTransformer">
	<mapping>xml/test-mapping.xml</mapping>			
</map:transformer>

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"
src="xsp/civicaLodgement.xsp">
				<!-- 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"/>
			</map:act>
			<!-- This part is called when the action executes
<action:set-failure/> 
			<map:generate type="serverpages" src="error.xsp"/>
			<map:serialize/>-->
		</map:match>

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

	<!-- 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
session:

<?xml version="1.0"?>
<civica xmlns:castor="http://castor.exolab.org/cocoontransfomer">	
	<castor:InsertBean name="lodgement" scope="session"/> 	
</civica>

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
transform.
If you spend a little time playing around with this, you'll begin to
appreciate its huge potential.

Regards,

Tony

-----Original Message-----
From: Uwe Gerger [mailto:Uwe.Gerger@bmw.de]
Sent: Wednesday, 16 July 2003 6:22 PM
To: users@cocoon.apache.org
Subject: Re: Beans as input for cocoon


Hello,
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!?

Thanks
	Uwe

> TEdwards@civica.com.au 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 [mailto:alasan@gmx.at]
> Sent: Wednesday, 16 July 2003 1:29 AM
> To: users@cocoon.apache.org
> 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: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org

Mime
View raw message