Search code examples
javaxslttransformhreftransformer-model

pass <xsl:param> to <a href>


I try to pass parameter

<xsl:param name="current_item" />

Before that I sent parameter as transformer.setParameter("current_item", "Ball");

But when I try to set this parameter as parameter

<a href="controller?command=transform&amp;current_item={$current_item}"></a>

In this row I get error Variable or parameter 'current_item' is undefined.' How I should specify this variable?


Solution

  • I resolved my problem by seting a global <xsl:param>.

    Before I had been using <xsl:param> in one from 2 <xsl:template> and tried to set in the href of another <xsl:template>.

    Excerpt from an answer to a similar question about the Usage of XSLT Parameters:

    <xsl:param> can be specified at the global level anywhere (as a child of xsl:stylesheet) or if it is within a template, it must be its child and it must precede any non-xsl:param child of xsl:template.

    This is the facility that allows a template or the whole transformation (in case of a global xsl:param) to receive varying data from the caller/initiator of the template or of the whole transformation, respectively.