You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Jozsa Kristof <dy...@kami.vein.hu> on 2001/11/15 17:50:30 UTC

Transformers vs. Generators

Okay, one piece of theoratical question. If I want to use xml data output
from a bunch of EJBs (JBoss+Cocoon stuff), shall I better write a
Transformer or a Generator for getting the data?

I'd vote for Transformers, which looks for xml tags in a source xml like
<customer-data/>, and replaces it with the business data coming from EJBs,
which gets rendered by an other (eg. the default XSLT) Transformer right
after.

Is that the correct way handling the situation?

Christopher
-- 
.Digital.Yearning.for.Networked.Assassination.and.Xenocide

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: Transformers vs. Generators

Posted by David Rosenstrauch <da...@dti.net>.
Also make sure that you declare this new transformer in your sitemap.


DR


At 09:13 PM 11/15/01 +0100, you wrote:
>Peter, exactly where had you put your own Transformers? I've tried to put it
>in my own package (not in org.apache.cocoon.transformation), jar-ed it
>correctly, dropped the jar into Cocoon's main WEB-INF/lib/, configured it
>in the sitemap, and got a ClassNotFoundException. Do I have to use the
>cocoon.transformation package for my Transformators, or where should I put
>it to let Cocoon to use it?
>
>Christopher
>-- 
>.Digital.Yearning.for.Networked.Assassination.and.Xenocide
>
>---------------------------------------------------------------------
>Please check that your question has not already been answered in the
>FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
>To unsubscribe, e-mail: <co...@xml.apache.org>
>For additional commands, e-mail: <co...@xml.apache.org> 


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: Transformers vs. Generators

Posted by Jozsa Kristof <dy...@kami.vein.hu>.
On Thu, Nov 15, 2001 at 03:31:09PM -0500, Peter Royal wrote:
> On Thursday 15 November 2001 03:13 pm, you wrote:
> > Peter, exactly where had you put your own Transformers? I've tried to put
> > it in my own package (not in org.apache.cocoon.transformation), jar-ed it
> > correctly, dropped the jar into Cocoon's main WEB-INF/lib/, configured it
> > in the sitemap, and got a ClassNotFoundException. Do I have to use the
> > cocoon.transformation package for my Transformators, or where should I put
> > it to let Cocoon to use it?
> 
> Thats pretty much what I did over here. One debugging check is to look at the 
> start of the cocoon.log and in there it enumerates its classpath that it 
> built from the lib directory. Make sure your jar is listed in there as a 
> starting point in debugging.
> 
> If the jar is there and you still have the error, email me the stack trace.
> -pete

Okay, figured it out. I wrote MyTransformer.class in the sitemap, where
providing the .class extension is actually an error. Yesterday I went home
after I couldn't even spell 'Exception' correctly in some other java source
of mine; today I've found the error in my Cocoon sitemap setup in minutes :)

I had to clear the Catalina cache (rm -rf work/*) in my JBoss+Tomcat's setup
though to get it work, but solved it at last as I said..

Thanks,
Christopher

-- 
.Digital.Yearning.for.Networked.Assassination.and.Xenocide

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: Transformers vs. Generators

Posted by Peter Royal <pr...@managingpartners.com>.
On Thursday 15 November 2001 03:13 pm, you wrote:
> Peter, exactly where had you put your own Transformers? I've tried to put
> it in my own package (not in org.apache.cocoon.transformation), jar-ed it
> correctly, dropped the jar into Cocoon's main WEB-INF/lib/, configured it
> in the sitemap, and got a ClassNotFoundException. Do I have to use the
> cocoon.transformation package for my Transformators, or where should I put
> it to let Cocoon to use it?

Thats pretty much what I did over here. One debugging check is to look at the 
start of the cocoon.log and in there it enumerates its classpath that it 
built from the lib directory. Make sure your jar is listed in there as a 
starting point in debugging.

If the jar is there and you still have the error, email me the stack trace.
-pete

-- 
peter royal -> proyal@managingpartners.com

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


SV: Transformers vs. Generators

Posted by Soren Neigaard <s....@mobilethink.dk>.
Sounds more like you need to put you jar in your ServletEngines classpath.

-----Oprindelig meddelelse-----
Fra: Jozsa Kristof [mailto:dynax@kami.vein.hu]
Sendt: 15. november 2001 12:14
Til: cocoon-users@xml.apache.org
Emne: Re: Transformers vs. Generators


On Thu, Nov 15, 2001 at 12:28:30PM -0500, Peter Royal wrote:
> On Thursday 15 November 2001 11:50 am, you wrote:
> > Okay, one piece of theoratical question. If I want to use xml data
output
> > from a bunch of EJBs (JBoss+Cocoon stuff), shall I better write a
> > Transformer or a Generator for getting the data?
> >
> > I'd vote for Transformers, which looks for xml tags in a source xml like
> > <customer-data/>, and replaces it with the business data coming from
EJBs,
> > which gets rendered by an other (eg. the default XSLT) Transformer right
> > after.
> >
> > Is that the correct way handling the situation?
>
> That works, but exception handling that way can be a pain because you can
> only throw a SAXException once the transformer gets going.
>
> I recently refactored my project to use a lot of transformers, I think its
> more manageable that way. I have a transformer that inserts data similar
to
> your need, and it works by loading the data in the setup() method, and
then
> spitting it out once the appropriate tag is seen.

Peter, exactly where had you put your own Transformers? I've tried to put it
in my own package (not in org.apache.cocoon.transformation), jar-ed it
correctly, dropped the jar into Cocoon's main WEB-INF/lib/, configured it
in the sitemap, and got a ClassNotFoundException. Do I have to use the
cocoon.transformation package for my Transformators, or where should I put
it to let Cocoon to use it?

Christopher
--
.Digital.Yearning.for.Networked.Assassination.and.Xenocide

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>




---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: Transformers vs. Generators

Posted by Jozsa Kristof <dy...@kami.vein.hu>.
On Thu, Nov 15, 2001 at 12:28:30PM -0500, Peter Royal wrote:
> On Thursday 15 November 2001 11:50 am, you wrote:
> > Okay, one piece of theoratical question. If I want to use xml data output
> > from a bunch of EJBs (JBoss+Cocoon stuff), shall I better write a
> > Transformer or a Generator for getting the data?
> >
> > I'd vote for Transformers, which looks for xml tags in a source xml like
> > <customer-data/>, and replaces it with the business data coming from EJBs,
> > which gets rendered by an other (eg. the default XSLT) Transformer right
> > after.
> >
> > Is that the correct way handling the situation?
> 
> That works, but exception handling that way can be a pain because you can 
> only throw a SAXException once the transformer gets going.
> 
> I recently refactored my project to use a lot of transformers, I think its 
> more manageable that way. I have a transformer that inserts data similar to 
> your need, and it works by loading the data in the setup() method, and then 
> spitting it out once the appropriate tag is seen.

Peter, exactly where had you put your own Transformers? I've tried to put it
in my own package (not in org.apache.cocoon.transformation), jar-ed it
correctly, dropped the jar into Cocoon's main WEB-INF/lib/, configured it
in the sitemap, and got a ClassNotFoundException. Do I have to use the
cocoon.transformation package for my Transformators, or where should I put
it to let Cocoon to use it?

Christopher
-- 
.Digital.Yearning.for.Networked.Assassination.and.Xenocide

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: Transformers vs. Generators

Posted by Peter Royal <pr...@managingpartners.com>.
On Thursday 15 November 2001 12:58 pm, you wrote:
> Can you handle situations using this approach where the data changes
> meanwhile? Does the setup() runs only once at Cocoon initialization or it
> runs once at every page request?

setup() is called for each request. If you need to do stuff just 1x ever, you 
can make your transformer Initializable and you can do that in the 
initialize() method.

> Thanks for the pieces of advice,

no problem.
-pete

-- 
peter royal -> proyal@managingpartners.com

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: Transformers vs. Generators

Posted by Jozsa Kristof <dy...@kami.vein.hu>.
On Thu, Nov 15, 2001 at 12:28:30PM -0500, Peter Royal wrote:
> On Thursday 15 November 2001 11:50 am, you wrote:
> > Okay, one piece of theoratical question. If I want to use xml data output
> > from a bunch of EJBs (JBoss+Cocoon stuff), shall I better write a
> > Transformer or a Generator for getting the data?
> >
> > I'd vote for Transformers, which looks for xml tags in a source xml like
> > <customer-data/>, and replaces it with the business data coming from EJBs,
> > which gets rendered by an other (eg. the default XSLT) Transformer right
> > after.
> >
> > Is that the correct way handling the situation?
> 
> That works, but exception handling that way can be a pain because you can 
> only throw a SAXException once the transformer gets going.
> 
> I recently refactored my project to use a lot of transformers, I think its 
> more manageable that way. 
I have a transformer that inserts data similar to 
> your need, and it works by loading the data in the setup() method, and then 
> spitting it out once the appropriate tag is seen.

Can you handle situations using this approach where the data changes
meanwhile? Does the setup() runs only once at Cocoon initialization or it
runs once at every page request? 

> throw a ProcessingException and there is the chance for a nice error page to 
> be shown to the user. Once the SAX stream starts going, an exception could 
> result in a 1/2 rendered page for the client, not good IMHO.

Yeah, clear.. very good point!

Thanks for the pieces of advice,

Christopher
-- 
.Digital.Yearning.for.Networked.Assassination.and.Xenocide

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: Transformers vs. Generators

Posted by Peter Royal <pr...@managingpartners.com>.
On Thursday 15 November 2001 11:50 am, you wrote:
> Okay, one piece of theoratical question. If I want to use xml data output
> from a bunch of EJBs (JBoss+Cocoon stuff), shall I better write a
> Transformer or a Generator for getting the data?
>
> I'd vote for Transformers, which looks for xml tags in a source xml like
> <customer-data/>, and replaces it with the business data coming from EJBs,
> which gets rendered by an other (eg. the default XSLT) Transformer right
> after.
>
> Is that the correct way handling the situation?

That works, but exception handling that way can be a pain because you can 
only throw a SAXException once the transformer gets going.

I recently refactored my project to use a lot of transformers, I think its 
more manageable that way. I have a transformer that inserts data similar to 
your need, and it works by loading the data in the setup() method, and then 
spitting it out once the appropriate tag is seen.

I like that approach because if there is an error loading the data I can 
throw a ProcessingException and there is the chance for a nice error page to 
be shown to the user. Once the SAX stream starts going, an exception could 
result in a 1/2 rendered page for the client, not good IMHO.

So my suggestion to you would be to see if you can load your customer data in 
the setup() of a transformer, and then only serialize it once the tag you are 
looking for is encountered.

I hope that makes sense :)
-pete

-- 
peter royal -> proyal@managingpartners.com

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: Transformers vs. Generators

Posted by David Rosenstrauch <da...@dti.net>.
Tough call.  I'd say it depends.  If <customer-data/> is going to be replaced with "John Brown, 40 Main St." then I'd say a transform.  If <customer-data/> is going to be replace with a large amount of other XML data (i.e., <records><record><field .../><field .../></record><record><field .../><field .../></record></records>) I might think about doing a generator.

I don't love the concept of transformers reading XML from another source and piping it.  Just my preference though - it's your call.


DR


At 05:50 PM 11/15/01 +0100, you wrote:
>Okay, one piece of theoratical question. If I want to use xml data output
>from a bunch of EJBs (JBoss+Cocoon stuff), shall I better write a
>Transformer or a Generator for getting the data?
>
>I'd vote for Transformers, which looks for xml tags in a source xml like
><customer-data/>, and replaces it with the business data coming from EJBs,
>which gets rendered by an other (eg. the default XSLT) Transformer right
>after.
>
>Is that the correct way handling the situation?
>
>Christopher
>-- 
>.Digital.Yearning.for.Networked.Assassination.and.Xenocide
>
>---------------------------------------------------------------------
>Please check that your question has not already been answered in the
>FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
>To unsubscribe, e-mail: <co...@xml.apache.org>
>For additional commands, e-mail: <co...@xml.apache.org> 


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>