xsl:variable 与 xsl:param - 中国WEB开发者网络 (http://www.webasp.net) -- 技术教程 (http://www.webasp.net/article/) --- xsl:variable 与 xsl:param (http://www.webasp.net/article/24/23785.htm) |
| -- 作者:未知 -- 发布日期: 2005-05-12 |
先看个例子: <xsl:call-template name="footer"><xsl:with-param name="date" select="@lastupdate"/></xsl:call-template> <xsl:template name="footer"> <xsl:param name="date">today</xsl:param> <hr/> <xsl:text>Last update: </xsl:text> <xsl:value-of select="$date"/></xsl:template> 对xml模板 来说,name属性是很关键的 call-template /apply-template 的name必须要和模板的name 相对应。模板相当于一个函数,可以暂时这么看。而name相当于函数名称把。 在call-template中 使用xsl:with-param 相当于函数参数输入 而参数声明相当就是在xsl:template的 xsl:param 说到xsl:variable。 可以用<xsl:variable name="ShowDepth"><计算的值></xsl:variable>来声明 相当于c中的 const 因为变量一旦声明就无法再被改变。 对于xsl:param和xsl:variable 都可以用 $+name 来直接选择比如 <xsl:value-of select="$date"/> 就是选择date变量或者参数 变量和参数,都是有声明范围的 这点和语言中的道理一样。 最后最最重要一点 :xsl的variable是常量不能再改变 不要被它的名称迷惑、 |
| webasp.net |