cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joerg Heinicke <joerg.heini...@gmx.de>
Subject Re: Request Parameter based Stylesheet selection
Date Fri, 08 Aug 2003 12:01:49 GMT
Hello Raman,

I don't know the RequestParameterMatcher, but from your code I wonder 
how it should work. At 
http://wiki.cocoondev.org/Wiki.jsp?page=WildcardRequestParameterMatcher 
there is an example and from it I think it should be something like the 
following:

<!-- only a better name to make it obvious -->
<map:matcher name="requestparam-id" 
src="org.apache.cocoon.matching.RequestParameterMatcher">
   <parameter-name>id</parameter-name>
</map:matcher>

<map:match pattern="xsp/invoice-control">
   <map:generate src="docs/xsp/invoice-control.xsp" type="serverpages"/>
   <!-- refering to the matcher above: @type -->
   <map:match type="requestparam-id" pattern="**">
     <map:transform src="invoicepresentation/xsl/report-{1}.xsl"/>
     <map:serialize/>
   </map:match>
</map:match>

Another possibility is the RequestParamAction:

<map:action name="request" 
src="org.apache.cocoon.acting.RequestParamAction"/>

<map:match pattern="xsp/invoice-control">
   <map:generate src="docs/xsp/invoice-control.xsp" type="serverpages"/>
   <map:act type="request">
     <map:parameter name="parameters" value="true"/>
     <map:transform src="invoicepresentation/xsl/report-{id}.xsl"/>
   </map:act>
   <map:serialize/>
</map:match>

(http://cocoon.apache.org/2.0/apidocs/org/apache/cocoon/acting/RequestParamAction.html)

But bear in mind that there is a certain risk using a request param 
directly for a URI to the file system. Imagine a parameter 
id=common/../../path/to/an/XSLT/the/user/should/not/see.xsl and having a 
directory report-common. Of course it's only theoretical, but ...

Regards,

Joerg


Raman Jankiram wrote:

> I have been struggling with this problem for the the past few days with 
> Cocoon2.
> 
> I have a XSP which generates XML (typical generator). I want to pick 
> style sheet based on the request parameters.
> 
> I have the sitemap like this
> <map:matchers>
> .
> .
>  <map:matcher  name="id" 
> src="org.apache.cocoon.matching.RequestParameterMatcher"/>
> .
> </map:matchers>
> .
> .
> .
> <map:match pattern="xsp/invoice-control">
>    <map:generate src="docs/xsp/invoice-control.xsp" type="serverpages"/>
>      <map:match name="id" pattern="**" >
>        <map:transform src="invoicepresentation/xsl/report-{1}.xsl">
>         </map:transform>
>        <map:serialize/>
>       </map:match>
> </map:match>
> 
> 
> the http request will be something like this
> http://www.jk.com/xsp/invoice-control?id=25
> 
> XSP generates the required XML from id=25 and we want the style sheet to 
> be applied.
> 
> For some reason this does not work.
> 
> Please help.
> -Raman


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


Mime
View raw message