You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Hewko, Doug" <Do...@ccra-adrc.gc.ca> on 2001/10/01 18:01:22 UTC

How to set up cocoon to pass parameters?

How can I set up cocoon to pass parameters from one file to another? For
now, I would be happy having the value of my parameter change when I click
on a link.

I am trying and this is the internal error I get:
2001-10-01 11:34:41 [org.apache.catalina.connector.warp.WarpConnector] Error
accepting requests
****************************************************************************
***************************
Here is my entry in my sitemap.xml file:
   <map:match pattern="test.html">
    <map:generate src="testing/test.xml"/>
    <map:transform src="testing/test.xsl"/>	 
     <map:parameter name="paramtest"/>	
	   <map:serialize type="html"/>	
   </map:match>   
****************************************************************************
***************************
Here is my XSL:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<!-- determine output of transform -->
<xsl:output method="html" encoding="iso-8859-1" indent="yes"/>

<xsl:param name="paramtest" select="on"/>
<!-- master template-->
<xsl:template match="/">
<html>
<body>
parameter value=<xsl:value-of select="$paramtest"/>
<br /><br />
xml value=<xsl:value-of select="//resource"/>
<xsl:variable name="something">ABC</xsl:variable>
<a href="\cocoon\test.html?paramtest=1234">Click here</a>
</body>
</html>

</xsl:template>

</xsl:stylesheet>

---------------------------------------------------------------------
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: How to set up cocoon to pass parameters?

Posted by Vadim Gritsenko <va...@verizon.net>.
There are couple of ways of achieving that.

---------------------------------------------------------------------------------------
FIRST WAY: Define (and use) transformer which would have access to ALL request parameters:
  <map:transformers default="xslt">
   ...
   <map:transformer name="xslt-with-params" src="org.apache.cocoon.transformation.TraxTransformer">
    <use-request-parameters>true</use-request-parameters>
   </map:transformer>
  </map:transformers>
  ...
>    <map:match pattern="test.html">
>     <map:generate src="testing/test.xml"/>
>     <map:transform type="xslt-with-params" src="testing/test.xsl"/>
>     <map:serialize type="html"/>	
>    </map:match>   

---------------------------------------------------------------------------------------
SECOND WAY: Use action and make only SOME request parameters available to stylesheets:
  <map:actions>
   <map:action name="request" src="org.apache.cocoon.acting.RequestParamAction"/>
  </map:actions>
  ...
>    <map:match pattern="test.html">
>     <map:generate src="testing/test.xml"/>
       <map:act type="request"> <!-- Makes all parameters accessible as {parameter-name} -->
         <map:transform type="xslt-with-params" src="testing/test.xsl">
           <map:parameter name="paramtest" value="{paramtest}"/>
           <!-- Define stylesheet parameter "paramtest" with value taken from request parameter "paramtest" -->
         <map:transform>
       </map:act>
>     <map:serialize type="html"/>	
>    </map:match>   


Second way is better if you care about how efficient Cocoon cache will work and if you are planning more then
one parameter, but just some of them are required in this stylesheet.

PS: I did not tested this, might have typos ;)

PPS: You sitemap snippet is not syntaxically correct. It should read:

>    <map:match pattern="test.html">
>     <map:generate src="testing/test.xml"/>
>     <map:transform src="testing/test.xsl">
>      <map:parameter name="paramtest" value="whatever-you-want"/>
>     </map:transform>
>     <map:serialize type="html"/>	
>    </map:match> 

Vadim

> -----Original Message-----
> From: Hewko, Doug [mailto:Doug.Hewko@ccra-adrc.gc.ca]
> Sent: Monday, October 01, 2001 12:01 PM
> To: 'cocoon-users@xml.apache.org'
> Subject: How to set up cocoon to pass parameters?
> 
> 
> How can I set up cocoon to pass parameters from one file to another? For
> now, I would be happy having the value of my parameter change when I click
> on a link.
> 
> I am trying and this is the internal error I get:
> 2001-10-01 11:34:41 [org.apache.catalina.connector.warp.WarpConnector] Error
> accepting requests
> ****************************************************************************
> ***************************
> Here is my entry in my sitemap.xml file:
>    <map:match pattern="test.html">
>     <map:generate src="testing/test.xml"/>
>     <map:transform src="testing/test.xsl"/>	 
>      <map:parameter name="paramtest"/>	
> 	   <map:serialize type="html"/>	
>    </map:match>   
> ****************************************************************************
> ***************************
> Here is my XSL:
> <?xml version="1.0" encoding="iso-8859-1"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> 
> <!-- determine output of transform -->
> <xsl:output method="html" encoding="iso-8859-1" indent="yes"/>
> 
> <xsl:param name="paramtest" select="on"/>
> <!-- master template-->
> <xsl:template match="/">
> <html>
> <body>
> parameter value=<xsl:value-of select="$paramtest"/>
> <br /><br />
> xml value=<xsl:value-of select="//resource"/>
> <xsl:variable name="something">ABC</xsl:variable>
> <a href="\cocoon\test.html?paramtest=1234">Click here</a>
> </body>
> </html>
> 
> </xsl:template>
> 
> </xsl:stylesheet>
> 
> ---------------------------------------------------------------------
> 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>