You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Jason Foster <ja...@engmail.uwaterloo.ca> on 2001/03/04 21:39:28 UTC

[C2] ScriptGenerator

I've put together a small generator that I would like to contribute to the
Cocoon2 project.  This generator uses the BSF framework to allow developers
to generate their XML using Python, JavaScript, etc.

Using the generator is as easy as adding the following to the sitemap:

<map:generator
     name="script"
     src="org.apache.cocoon.generation.ScriptGenerator"/>

<map:match pattern="scripts/*">
 <map:generate type="script" src="docs/samples/{1}"/>
 <map:transform src="stylesheets/page/simple-page2html.xsl"/>
 <map:serialize type="html"/>
</map:match>

Within your script you have access to all of the generator objects that
looked interesting, including the Cocoon Logger.  XML is passed from the
script to Cocoon using a StringBuffer named "output".  Check out the
examples for more details.

Cocoon2 already includes the Rhino JavaScript interpreter, so .js files will
work immediately.  You can get the Jython interpreter at www.jython.org, and
hopefully jython.jar will make it into the Cocoon2 distribution.

What I think might be interesting is that there is some early support for
Perl in the BSF.  This might allow an elegant transition from Perl/CGI sites
to Cocoon sites.

I have attached a .tar.gz with the code.  Any comments on the code, style,
approach, etc. would be greatly appreciated.

Jason Foster


Re: [C2] ScriptGenerator

Posted by Giacomo Pati <gi...@apache.org>.
Jason, If checked in your ScriptGenerator.

Could you please cross check it?

Thanks,

Giacomo

Jason Foster wrote:

> > I've put together a small generator that I would like to contribute to the
> Cocoon2 project.  This generator uses the BSF framework to allow developers
> to generate their XML using Python, JavaScript, etc.
>
> Using the generator is as easy as adding the following to the sitemap:
>
> <map:generator
>      name="script"
>      src="org.apache.cocoon.generation.ScriptGenerator"/>
>
> <map:match pattern="scripts/*">
>  <map:generate type="script" src="docs/samples/{1}"/>
>  <map:transform src="stylesheets/page/simple-page2html.xsl"/>
>  <map:serialize type="html"/>
> </map:match>
>
> Within your script you have access to all of the generator objects that
> looked interesting, including the Cocoon Logger.  XML is passed from the
> script to Cocoon using a StringBuffer named "output".  Check out the
> examples for more details.
>
> Cocoon2 already includes the Rhino JavaScript interpreter, so .js files
> will work immediately.  You can get the Jython interpreter at
> www.jython.org, and hopefully jython.jar will make it into the Cocoon2
> distribution.
>
> What I think might be interesting is that there is some early support for
> Perl in the BSF.  This might allow an elegant transition from Perl/CGI
> sites to Cocoon sites.
>
> I have attached a .tar.gz with the code.  Any comments on the code, style,
> approach, etc. would be greatly appreciated.
>
> Jason Foster

----------------------------------------
Content-Type: application/x-gzip; charset="US-ASCII"; 
name="ScriptGenerator.tar.gz"
Content-Transfer-Encoding: base64
Content-Description: 
----------------------------------------

----------------------------------------
Content-Type: text/plain; charset="us-ascii"; name="Anhang: 2"
Content-Transfer-Encoding: 7bit
Content-Description: 
----------------------------------------

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