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/02/20 19:31:56 UTC
Design for a BSF Producer
Long time lurker, second time poster...
A while back I created a rather nasty hacked Python producer for Cocoon 1.8.
I would like to develop a "proper" generator for Cocoon2 and was hoping to
get some feedback from the list as to the best way to hook into the sitemap.
Please take a look at the following message and give me some feedback
regarding my approach/syntax/etc.
I think that I could use XSP instead of a custom generator to accomplish my
goals. Personally I see the solution I am proposing as being better since I
don't have to worry about dynamic compilation, etc. Any comments on my
(provisionary) decision would be appreciated.
----------
What I am envisioning is a "ScriptProducer" that will use the BSF framework
to allow any Java-based scripting language to act as a producer.
The script would be passed a data structure containing the request
parameters and would deposit the resulting XML document into a string. The
environment would extract the string and would send it through the rest of
the pipeline. I though about having the script generate SAX events and
decided that was more than complicated than I wanted to get for now.
I'm a little shaky on what the best way to hook into the sitemap would be.
My first guess is that I need both a producer and a chooser. The chooser
would use the extension of the script file to determine if the appropriate
classes and BSF drivers were available. I think this would look something
like:
<map:generator name="script"
src="org.apache.cocoon.generation.ScriptGenerator"/>
<map:selector name="script"
factory="org.apache.cocoon.selection.ScriptSelectorFactory"/>
...
<map:match pattern="scripts/*">
<map:select type="script">
<map:when test="script">
<map:generate type="script" src="docs/scripts/{1}"/>
</map:when>
<map:otherwise>
<map:generate src="scripterror.xml"/>
</map:otherwise>
</map:select>
<map:transform src="stylesheets/transforms.xsl"/>
<map:serialize type="html"/>
</map:match>
So in a nutshell I have a way to determine whether or not a particular
script name is valid and a way to generate content from the script. Ideally
I would be able to configure the generator so that I can specify in the
sitemap what the name of the parameter variable will be and what the name of
the string containing the resulting XML document is. I have no idea how to
accomplish this part of the plan.
The basic BSF distribution provides enough sample code for me to know that
all of the things I need to do are possible. Where I'm having trouble is
figuring out the Cocoon2 side of things.
Any assistance/pointers/comments/critiques would be appreciated.
Jason Foster