You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Tennile Christensen <te...@kidar.org> on 2001/09/19 20:31:49 UTC

xsl:apply-templates and xsl:with-param

Hi all,

I'm having a problem using xsl:apply-templates and xsl:with-param. If
anyone has successfully done this before and can let me know where I'm
going wrong, I'd really appreciate it.

I have several templates like the following:

<xsl:template match="s4">

<br></br>
<p class="H4">
<xsl:if test="@indexterm">
<A NAME="{@indexterm}">
</A>
</xsl:if>

<A><xsl:attribute name="NAME"><xsl:value-of select="translate(heading,'
','')"/></xsl:attribute></A>
<xsl:value-of select="heading"/>
</p>

<xsl:apply-templates>
<xsl:with-param name="style" select="'body-s4'"/>
</xsl:apply-templates>

</xsl:template>

The template above matches several different templates in an
xsl:include(ed) stylesheet, which
attempt to use the $style parameter, like the following:

                          <!-- P (paragraphs) -->
<xsl:template match="p">
<p>
<xsl:attribute name="class"> <xsl:value-of select="$style"/>
</xsl:attribute>
<xsl:apply-templates/>
</p>
</xsl:template>

But, I'm getting the following error. The output contains the class
attribute set to an empty string.

file:/shome/tennille/p4/wacdem_A_1/doc/dtd/block_hand.xsl; Line 55;
Column -1; VariableReference given for variable out of context or
without definition!  Name = style
file:/shome/tennille/p4/wacdem_A_1/doc/dtd/block_hand.xsl; Line 16;
Column -1; VariableReference given for variable out of context or
without definition!  Name = style


Am I missing anything? Or should I submit this as a bug?



Thanks for your time,
Tennille


RE: apply-templates and xsl:with-param

Posted by Gary L Peskin <ga...@firstech.com>.
It looks like you need an <xsl:param ...> within your xsl:template in
order to "receive" the passed parameter.

Gary

> -----Original Message-----
> From: Tennile Christensen [mailto:tennille@kidar.org] 
> Sent: Wednesday, September 19, 2001 11:32 AM
> To: xalan-j-users@xml.apache.org
> Subject: xsl:apply-templates and xsl:with-param
> 
> 
> Hi all,
> 
> I'm having a problem using xsl:apply-templates and 
> xsl:with-param. If anyone has successfully done this before 
> and can let me know where I'm going wrong, I'd really appreciate it.
> 
> I have several templates like the following:
> 
> <xsl:template match="s4">
> 
> <br></br>
> <p class="H4">
> <xsl:if test="@indexterm">
> <A NAME="{@indexterm}">
> </A>
> </xsl:if>
> 
> <A><xsl:attribute name="NAME"><xsl:value-of 
> select="translate(heading,' ','')"/></xsl:attribute></A> 
> <xsl:value-of select="heading"/> </p>
> 
> <xsl:apply-templates>
> <xsl:with-param name="style" select="'body-s4'"/> 
> </xsl:apply-templates>
> 
> </xsl:template>
> 
> The template above matches several different templates in an
> xsl:include(ed) stylesheet, which
> attempt to use the $style parameter, like the following:
> 
>                           <!-- P (paragraphs) -->
> <xsl:template match="p">
> <p>
> <xsl:attribute name="class"> <xsl:value-of select="$style"/> 
> </xsl:attribute> <xsl:apply-templates/> </p> </xsl:template>
> 
> But, I'm getting the following error. The output contains the 
> class attribute set to an empty string.
> 
file:/shome/tennille/p4/wacdem_A_1/doc/dtd/block_hand.xsl; Line 55;
Column -1; VariableReference given for variable out of context or
without definition!  Name = style
file:/shome/tennille/p4/wacdem_A_1/doc/dtd/block_hand.xsl; Line 16;
Column -1; VariableReference given for variable out of context or
without definition!  Name = style


Am I missing anything? Or should I submit this as a bug?



Thanks for your time,
Tennille