You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Chintalapaty, Sreedhar " <sc...@ptc.com> on 2003/07/07 18:04:54 UTC

Custom Logic Sheets: Request Parameters in Nested tags

Hi,

I am trying to develop a tag that would 
  - Get a parameter called "template-id" from the request
  - Fetch the template with that template-id from an XML config file

Here's is how I am trying to accomplish it:

<!-- ===================================================================== -->
<!-- Fetch the template matching tempalte-id in Request -->
<xsl:template match="gvs:fetch-template">
  <!-- Get template-id -->
  <xsl:variable name="id">'<request:get-parameter name="template-id"/>'</xsl:variable>

  <xsl:variable name="query-template">
   <xsl:call-template name="get-template">
     <xsl:with-param name="id" select="$id"/>
   </xsl:call-template>	
  </xsl:variable>
  <xsl:value-of select="$query-template"/>	
</xsl:template>


<!-- Get Query Template from queries.xml, given its ID -->
<xsl:template name="get-template">
  <xsl:param name="id"/>
  <xsl:variable name="query-template" select="document('../control/config/queries.xml')/gvs-site:queries/gvs-site:query[@id=$id]/template"/>
  <xsl:value-of select="normalize-space($query-template)"/>
</xsl:template>

<!-- ===================================================================== -->

For reasons that I cannot think of, this does NOT work!

Interestingly, the following tag (which is essentially the "<!-- Get template-id -->" section of the fetch-template tag) will correctly read the template-id from the request: 

<!-- Get the Template ID from Request -->
<xsl:template match="gvs:get-it">
  <xsl:variable name="id">'<request:get-parameter name="template-id"/>'</xsl:variable>
  <xsl:copy-of select="$id"/>	
</xsl:template>

Also, If set the template-id to a static value in the fetch-template tag, it will return the correct template from the XML file.

So the questions I have are:
1. How can I get this to work? Are there any other suggested methods?
2. Why does the tag fail as it exists?

I'd be grateful for any answers/pointers to the manuals/old threads, etc. :)

Thanks,

Sreedhar
PS: I am using Cocoon 2.0.4 with Tomcat 4.1 and Java 2 SE 1.3.1_07-b02




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


Re: Custom Logic Sheets: Request Parameters in Nested tags

Posted by Joerg Heinicke <jo...@gmx.de>.
Remove the apostrophes:

<xsl:variable name="id">
   <request:get-parameter name="template-id"/>
</xsl:variable>

Joerg


Chintalapaty, Sreedhar wrote:
> Hi,
> 
> I am trying to develop a tag that would 
>   - Get a parameter called "template-id" from the request
>   - Fetch the template with that template-id from an XML config file
> 
> Here's is how I am trying to accomplish it:
> 
> <!-- ===================================================================== -->
> <!-- Fetch the template matching tempalte-id in Request -->
> <xsl:template match="gvs:fetch-template">
>   <!-- Get template-id -->
>   <xsl:variable name="id">'<request:get-parameter name="template-id"/>'</xsl:variable>
> 
>   <xsl:variable name="query-template">
>    <xsl:call-template name="get-template">
>      <xsl:with-param name="id" select="$id"/>
>    </xsl:call-template>	
>   </xsl:variable>
>   <xsl:value-of select="$query-template"/>	
> </xsl:template>
> 
> 
> <!-- Get Query Template from queries.xml, given its ID -->
> <xsl:template name="get-template">
>   <xsl:param name="id"/>
>   <xsl:variable name="query-template" select="document('../control/config/queries.xml')/gvs-site:queries/gvs-site:query[@id=$id]/template"/>
>   <xsl:value-of select="normalize-space($query-template)"/>
> </xsl:template>
> 
> <!-- ===================================================================== -->
> 
> For reasons that I cannot think of, this does NOT work!
> 
> Interestingly, the following tag (which is essentially the "<!-- Get template-id -->" section of the fetch-template tag) will correctly read the template-id from the request: 
> 
> <!-- Get the Template ID from Request -->
> <xsl:template match="gvs:get-it">
>   <xsl:variable name="id">'<request:get-parameter name="template-id"/>'</xsl:variable>
>   <xsl:copy-of select="$id"/>	
> </xsl:template>
> 
> Also, If set the template-id to a static value in the fetch-template tag, it will return the correct template from the XML file.
> 
> So the questions I have are:
> 1. How can I get this to work? Are there any other suggested methods?
> 2. Why does the tag fail as it exists?
> 
> I'd be grateful for any answers/pointers to the manuals/old threads, etc. :)
> 
> Thanks,
> 
> Sreedhar
> PS: I am using Cocoon 2.0.4 with Tomcat 4.1 and Java 2 SE 1.3.1_07-b02


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