cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steven J. Burr <>
Subject Re: basic form tutorial
Date Sun, 17 Aug 2003 16:59:53 GMT
I managed to get this to work for a similar application.  Instead of  
using the

<map:parameter name="varname" value="{request-param:varname}"/>

element, I simply added

<map:parameter name="use-request-parameters" value="true"/>

to my map:transform element.   This gives my stylesheet access to the  
request parameters, which are used to filter the data presented to the  

I'm new too, so this may not be the best approach, but it's working in  
Cocoon 2.1 on my system.

FWIW, the relevant pipeline in my sub-sitemap looks like this:

     <!-- Use a directory generator to output an aggregation of all  
     	 documents and an index page. Request parameters are passed to the
     	 stylesheet and used to select policies and policy sections
     	 addressing a particular core function and/or program.  -->
     	<map:match pattern="policies/all_policies">
     		<map:generate src="policies" type="directory">
     			<map:parameter name="depth" value="1"/>
     		<map:transform src="stylesheets/all_policies.xsl"/>
     		<map:serialize type="xml"/>
         <map:match pattern="policies/index">
     		<map:generate src="cocoon:/policies/all_policies"/>
     		<map:transform src="stylesheets/policy_index.xsl">
     			<map:parameter name="use-request-parameters" value="true"/>
     		<map:serialize type="html"/>

And here are the templates from the policy_index.xsl stylesheet that  
create the form.  (I use the document function earlier in the  
stylesheet to access the schema for the policy document.)

<xsl:template match="xs:schema">
     <form action="index" method="GET">
     <table cellpadding="5">
         <td>By Program:</td>
         <select name="prog">
         <td>By Core Function:</td>
         <select name="cf">
     <input type="submit" value="Apply"/>

<xsl:template match="xs:attribute/xs:simpleType">
     <xsl:for-each select="xs:restriction/xs:enumeration">
         <xsl:sort select="@value"/>
         <option value="{@value}">
             <xsl:value-of select="@value"/>

On Friday, Aug 15, 2003, at 23:11 America/Phoenix, Ben Munat wrote:

> Thanks guys. This sounds really easy. Unfortunately, I haven't been  
> able to get it to work yet.
> I checked my cocoon.xconf file and the RequestParameterModule is just  
> as the wiki page says it should be. I edited the map:transform element  
> of the page's pipeline to include the parameters (<map:parameter  
> name="artist" value="{request-param:artist}"/>). And I declared the  
> parameters as top-level params and then tried to get their values  
> (with <xsl:value-of select="$title"/> etc.). But when I put something  
> into a form field and submit it, I get nuttin... the page reloads, but  
> the variables are still empty.
> Might there be another configuration thing I'm missing? Or maybe I'm  
> just not doing something really obvious... that's my specialty. Well,  
> at least all the variable names are all lower case, and I checked  
> thoroughly for typos! ;o)
> Other ideas appreciated.
> Ben
> Geoff Howard wrote:
>> Conal Tuohy wrote:
>>> Ben, you can pass the form values to your XSLT something like this:
>>> <map:transform src="song-list-to-html.xsl">
>>>     <map:parameter         name="artist"          
>>> value="{request-param:artist}"/>
>>>     <map:parameter         name="title"          
>>> value="{request-param:title}"/>
>>>     <map:parameter         name="style"          
>>> value="{request-param:style}"/>
>>> </map:transform>
>>> Check out the RequestParameterModule:
>> And to use them in your stylesheet you need to define those three  
>> values as top-level xsl:param elements:
>> <xsl:stylesheet version="1.0"  
>> xmlns:xsl="";>
>>     <xsl:param name="artist"/>
>>     <xsl:param name="title"/>
>>     <xsl:param name="style"/>
>> ....
>> This is the same way you'd access external params sent to a  
>> transformation in standard xslt from the command line.
>> For this simple case, don't get bogged down in the frameworks you  
>> mentioned.  When you start getting into more complex needs, they'll  
>> be appropriate but they're not _necessary_ and will cloud the  
>> simplicity of Cocoon while you're just getting started.
>> Geoff
>>>> Hello. I'm very new to Cocoon and certainly no xml/programming/web  
>>>> wizard. I have an html page created by an xlst and served by  
>>>> cocoon. The source xml file is a list of songs; the xslt converts  
>>>> the songlist into a table and puts it on a page below a basic  
>>>> header/navbar and a box with some form inputs ("artist" and "title"  
>>>> text boxes and a "style" dropdown) for searching. Now the trick is  
>>>> to get cocoon to reload the page -- after I've entered something in  
>>>> these widgets and clicked submit -- and only display the entries  
>>>> from the songlist that match this criteria.
>>>> I've poked around the wiki and the docs and searched the mailing  
>>>> list and, well, I'm more confused than ever. Often the material is  
>>>> over my head, and oriented-towards doing something fancier than I  
>>>> need; form validation, database interaction and the like.
>>>> All I want to do is get the values of three post variables and fill  
>>>> the table of song data accordingly. Do I turn my xml file into an  
>>>> xsp and put java code in to interpret the post vars? Do I use some  
>>>> other component for this (an action... or this woody thing I keep  
>>>> hearing about)? Is there a tutorial out there that I've missed that  
>>>> has very basic instructions on using form vars?
>>>> Thanks,
>>>> Ben
>>>> -------------------------------------------------------------------- 
>>>> -
>>>> To unsubscribe, e-mail:
>>>> For additional commands, e-mail:
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail:
>>> For additional commands, e-mail:
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> For additional commands, e-mail:
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message