You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Anders Forsgren <an...@digitalfarmers.com> on 2003/12/17 00:36:11 UTC

map:parameter and xsl defaults

Hi all

I want to use a request param passed on as an argument to a transform.
The sitemap snippet looks like this:

<map:match pattern="log">
         <map:generate src="log/log.xml"/>
         <map:transform src="log/log2page.xsl"> 
               <map:parameter name="start" value="{request-param:start}"/>
               <map:parameter name="end" value="{request-param:end}"/>
         </map:transform>
         <map:serialize type="xml"/>
 </map:match>

In the log2page.xsl file, I have defaults for the parameters, for example
<xsl:param name="end" select="'100'"/>  

The default values are never assigned, which means the transform only 
works when both parameters are specified in the request params. What 
will the {request-param:foo} be replaced with when a param is not 
specified in the request? I don't know about empty versus "undefined" 
parameters, I wonder if the sitemap somehow passes an "empty but still 
valid/defined" (like a "" String versus the null String) -parameter to 
the xsl that prevents the defaults from being used?

If  I don't use any map:params with my transform, the defaults are used 
correctly inthe xsl.

Do I have to use a sitemap swicth to do the transform without 
map:parameter when the request parameters are missing, and with 
map:parameter when they exist? Seems like a lot of work, and also makes 
the xsl defaults unusable...
Am I missing the simple solution here?

rgds
Anders




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


Re: map:parameter and xsl defaults

Posted by Tony Collen <co...@umn.edu>.
Anders Forsgren wrote:
> Hi all
> 
> I want to use a request param passed on as an argument to a transform.
> The sitemap snippet looks like this:
> 
> <map:match pattern="log">
>         <map:generate src="log/log.xml"/>
>         <map:transform src="log/log2page.xsl">               
> <map:parameter name="start" value="{request-param:start}"/>
>               <map:parameter name="end" value="{request-param:end}"/>
>         </map:transform>
>         <map:serialize type="xml"/>
> </map:match>
> 
> In the log2page.xsl file, I have defaults for the parameters, for example
> <xsl:param name="end" select="'100'"/> 
> The default values are never assigned, which means the transform only 
> works when both parameters are specified in the request params. What 
> will the {request-param:foo} be replaced with when a param is not 
> specified in the request? I don't know about empty versus "undefined" 
> parameters, I wonder if the sitemap somehow passes an "empty but still 
> valid/defined" (like a "" String versus the null String) -parameter to 
> the xsl that prevents the defaults from being used?
> If  I don't use any map:params with my transform, the defaults are used 
> correctly inthe xsl.
> 
> Do I have to use a sitemap swicth to do the transform without 
> map:parameter when the request parameters are missing, and with 
> map:parameter when they exist? Seems like a lot of work, and also makes 
> the xsl defaults unusable...
> Am I missing the simple solution here?

Anders,

If you use the request-param input module, and try to get a parameter 
that does not exist, I believe you get "null" back.  If you want to 
prevent this, you could use the ChainMetaModule to "fall-back" to other 
modules or values... this would be the easiest way to ensure getting a 
value back.

> 
> rgds
> Anders

Tony


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