You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Sylvain Fétiveau <sy...@webmotion.com> on 2001/11/06 15:55:43 UTC

Passing parameter to a XSL stylesheet in the tag

Hi !

	I'd like to pass a parameter to a XSL stylesheet in sitemap.xmap
(precisely, I'd like to pass a kind of path of the generated file to the
XSL stylesheet). I use cocoon 2 with Tomcat 4. Currently, here is what I
do :

in sitemap.xmap:

   <map:match pattern="**.html">
    <map:aggregate element="root">
     <map:part src="site/site.xml"/>
     <map:part src="bodies/{1}.xml"/>
    </map:aggregate>
    <map:transform src="stylesheets/skeletons/variant.xsl">
     <map:parameter name="use-request-parameters" value="true"/>
     <map:parameter name="test" value="testtest"/>
    </map:transform>
    <map:serialize/>
   </map:match>

in variant.xsl:

    <xsl:template match="/root/site">
        <xsl:value-of select="$test"/>
    </xsl:template>

When I have the tag <xsl:value-of select="$test"/>, I get the following
error:

org.apache.cocoon.ProcessingException: Failed to execute pipeline.:
  java.lang.RuntimeException: Problem in getTransformer:Error in
creating
  Transform Handler
org.apache.cocoon.ProcessingException: Failed to execute pipeline.:
  java.lang.RuntimeException: Problem in getTransformer:Error in
creating
  Transform Handler
at org.apache.cocoon.components.pipeline.CachingStreamPipeline.process
  (CachingStreamPipeline.java:379)
at org.apache.cocoon.www.experiment.sitemap_xmap.wildcardMatchN400054
  (sitemap_xmap.java:566)
at org.apache.cocoon.www.experiment.sitemap_xmap.process
  (sitemap_xmap.java:317)
at org.apache.cocoon.www.experiment.sitemap_xmap.process
  (sitemap_xmap.java:269)
...

I guess that I miss something to pass or get the parameter. I tried with
aggregate and with just a single XML file, with use-request-parameters
enabled and disabled, nothing seems to work. I must have missed
something in the XSL code ; is there some kind of variable declaration
to do ?

Thanks.

Sylvain

---------------------------------------------------------------------
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: Passing parameter to a XSL stylesheet in the tag

Posted by David Rosenstrauch <da...@dti.net>.
In your XSL:

<xsl:stylesheet ...
         <xsl:param name="test"/>
...
     <xsl:template match="/root/site">
         <xsl:value-of select="$test"/>
     </xsl:template>



At 09:55 AM 11/6/01 -0500, you wrote:
>Hi !
>
>         I'd like to pass a parameter to a XSL stylesheet in sitemap.xmap
>(precisely, I'd like to pass a kind of path of the generated file to the
>XSL stylesheet). I use cocoon 2 with Tomcat 4. Currently, here is what I
>do :
>
>in sitemap.xmap:
>
>    <map:match pattern="**.html">
>     <map:aggregate element="root">
>      <map:part src="site/site.xml"/>
>      <map:part src="bodies/{1}.xml"/>
>     </map:aggregate>
>     <map:transform src="stylesheets/skeletons/variant.xsl">
>      <map:parameter name="use-request-parameters" value="true"/>
>      <map:parameter name="test" value="testtest"/>
>     </map:transform>
>     <map:serialize/>
>    </map:match>
>
>in variant.xsl:
>
>     <xsl:template match="/root/site">
>         <xsl:value-of select="$test"/>
>     </xsl:template>
>
>When I have the tag <xsl:value-of select="$test"/>, I get the following
>error:
>
>org.apache.cocoon.ProcessingException: Failed to execute pipeline.:
>   java.lang.RuntimeException: Problem in getTransformer:Error in
>creating
>   Transform Handler
>org.apache.cocoon.ProcessingException: Failed to execute pipeline.:
>   java.lang.RuntimeException: Problem in getTransformer:Error in
>creating
>   Transform Handler
>at org.apache.cocoon.components.pipeline.CachingStreamPipeline.process
>   (CachingStreamPipeline.java:379)
>at org.apache.cocoon.www.experiment.sitemap_xmap.wildcardMatchN400054
>   (sitemap_xmap.java:566)
>at org.apache.cocoon.www.experiment.sitemap_xmap.process
>   (sitemap_xmap.java:317)
>at org.apache.cocoon.www.experiment.sitemap_xmap.process
>   (sitemap_xmap.java:269)
>...
>
>I guess that I miss something to pass or get the parameter. I tried with
>aggregate and with just a single XML file, with use-request-parameters
>enabled and disabled, nothing seems to work. I must have missed
>something in the XSL code ; is there some kind of variable declaration
>to do ?
>
>Thanks.
>
>Sylvain
>
>---------------------------------------------------------------------
>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>