You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Geoff Howard <co...@leverageweb.com> on 2003/02/01 04:47:55 UTC

RE: Question on generators...

Then yes, you can reuse it - but you should be aware that it's not very
optimized doing xml generation through string.  If you're doing short
documents, you may not notice any issue.  But if you have a larger document
you may wish to reimplement in SAX.  Try it first as is - you may be
perfectly satisfied.

The short answer about how is basically:
1) Make sure you read up on Generators, including the tutorial on
CustomGenerators if you haven't already.  Also read up on Avalon (the stuff
at in the Cocoon docs should be enough).
2) Create a generator that imports your original class, and populate a
String in your Generator by calling appropriate methods in your class.
Exactly how is 100% determined by the specifics of how it works now, but I
trust you can figure that part out.

I have to gloss over the next details I think until I know what version
you're using:
3) Lookup the parser from Cocoon's ComponentManager (which means your
Generator needs to extend ComposerGenerator, or implement Composable
itself).
4) Do InputSource inputSource = new InputSource(new StringReader(
yourXMLString ));
5) Pass that inputSource to parse();

What version of Cocoon are you using? 2.0.3, 2.0.4, or 2.1dev?

If you're using 2.1dev, check out WebServiceProxyGenerator (quick before
someone refactors it to not use String anymore).  It does almost exactly
what you want, except it gets the String over HTTP from any arbitrary url.
In fact, you may look into that as a quick option.  Don't know your current
setup, but if you can call the servlet and get xml string back via HTTP you
could be finished quite quickly.

HTH,
Geoff Howard

> -----Original Message-----
> From: SriKumar Kareti [mailto:srikumar.kareti@spanlink.com]
> Sent: Friday, January 31, 2003 2:08 PM
> To: cocoon-users@xml.apache.org
> Subject: RE: Question on generators...
>
>
>
> Geoff,
>
> I was creating String...
>
> thx...
>
> -----Original Message-----
> From: Geoff Howard [mailto:cocoon@leverageweb.com]
> Sent: Friday, January 31, 2003 12:28 PM
> To: cocoon-users@xml.apache.org
> Subject: RE: Question on generators...
>
>
> This all depends on what you were doing in your class.  Were you
> creating
> xml?  If so, DOM, SAX or String?
>
> Geoff
>
> > -----Original Message-----
> > From: SriKumar Kareti [mailto:srikumar.kareti@spanlink.com]
> > Sent: Friday, January 31, 2003 10:21 AM
> > To: cocoon-users@xml.apache.org
> > Subject: Question on generators...
> >
> >
> >
> > Thanks for you help in advance...
> >
> > I am a new user to Cocoon. I have searched the site pretty well and
> > could
> > not answer this question. Could someone help...
> >
> > My goal is to move from current servlet based solution to Cocoon. The
> > general
> > flow of my current program is
> >
> > 1) Take the request,
> > 2) Generate the XML by making calls to Database based on the
> parameters
> >    passed...
> > 3) Use XSLT to generate html which is returned...
> >
> > Now I'd like to move to cocoon. I want to use my existing Java class
> > as the generator in Cocoon.
> >
> > Can I do that?
> >
> > SriKumar.
> >
> > ---------------------------------------------------------------------
> > Please check that your question  has not already been answered in the
> > FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.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/faq/index.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/faq/index.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/faq/index.html>

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