在 XSLT 中声明全局变量,在本地重新赋值 [英] Declare global variable in XSLT ,re-assign a value locally

查看:38
本文介绍了在 XSLT 中声明全局变量,在本地重新赋值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在全局范围内声明一个值为111"的变量myVariable".但是我怎样才能在本地重新分配一个值.或者有没有其他方法可以实现这一点.

I can declare a variable "myVariable" with a value "111" in the global scope. But how can I re-assign a value locally. Or is there a alternative way to achieve this.

请帮忙.谢谢你.拉维

推荐答案

您可以在模板内重新定义相同的变量:

You can re-define the same variable inside a template:

<xsl:variable name="myVariable" select="'111'"/>

<xsl:template match="/">
  <xsl:variable name="myVariable" select="'112'"/>
  . . . 
</xsl:template>

请注意,尽管 XSLT 中的变量"实际上是常量 - 您不是将不同的值重新分配给同一变量,而是在模板内部重新定义它 - 在模板外部 myVariable仍将具有 111 值.

Note though that 'variables' in XSLT are actually constant - you are not re-assigning a different value to the same variable, you are re-defining it inside the template - outside the template myVariable will still have the value 111.

这篇关于在 XSLT 中声明全局变量,在本地重新赋值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆