简体   繁体   English

通过 <xsl:param> 至

[英]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"); 在此之前我发送参数为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.' 在这一行中,我得到错误变量或参数'current_item'未定义。 How I should specify this variable? 我该如何指定这个变量?

I resolved my problem by seting a global <xsl:param> . 我通过设置全局<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> . 在我从2 <xsl:template>使用<xsl:param>并尝试在另一个<xsl:template>的href中设置之前。

Excerpt from an answer to a similar question about the Usage of XSLT Parameters: 摘自关于XSLT参数用法的类似问题的答案:

<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 . <xsl:param>可以在任何地方的全局级别指定(作为xsl:stylesheet的子级),或者如果它在模板中,它必须是它的子级,并且它必须位于xsl:template任何非xsl:param子级之前。

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. 这是允许模板或整个转换(在全局xsl:param情况下)分别从模板的调用者/发起者或整个转换接收变化数据的工具。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM