以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 XSL/XSLT/XSL-FO/CSS 』  (http://bbs.xml.org.cn/list.asp?boardid=8)
----  大家帮忙看一看:一个困惑了我两天的问题  (http://bbs.xml.org.cn/dispbbs.asp?boardid=8&rootid=&id=7473)


--  作者:Cindylm
--  发布时间:5/13/2004 4:21:00 PM

--  大家帮忙看一看:一个困惑了我两天的问题
我在《xslt程序员参考手册》上看到一个例子:
<xsl:variable name="new-filename">
  <xsl:call-template name="change"/>
</xsl:variable>
书中解释说变量new-filename的值为临时树,但实际上我们把它当作一个字符串;于是我做了一下测试:
在一个模板内部写了如下语句:
<xsl:variable name="new-filename">
   <xsl:call-template name="change"/>123
</xsl:variable>
<xsl:element name="input">
  <xsl:attribute name="value">
    <xsl:value-of  select="$new-filename">
  </xsl:attribute>
</xsl:element>
但结果,在生成的文本框里只有123,而没有模板生成的内容,这是为什么呢?
--  作者:KAI
--  发布时间:5/15/2004 2:28:00 PM

--  
<xsl:call-template name="change"/>

这个name="change"的template内容请你列出来。


--  作者:Cindylm
--  发布时间:5/16/2004 2:06:00 PM

--  
<xsl:template  name="Change">
    <xsl:element  name="input">
       <xsl:attribute  name="type">button</xsl:attribute>
       <xsl:attribute  name="value">你好</xsl:attribute>
    </xsl:element>
</xsl:template>
--  作者:sam
--  发布时间:5/17/2004 10:53:00 AM

--  
<?xml version="1.0" encoding="GB2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="new-filename">
   <xsl:call-template name="change"/>
</xsl:variable>
<xsl:template match="/">
<xsl:copy-of select="$new-filename"/>
</xsl:template>
<xsl:template  name="change">
    <xsl:element  name="input">
       <xsl:attribute  name="type">button</xsl:attribute>
       <xsl:attribute  name="value">你好</xsl:attribute>
    </xsl:element>
</xsl:template>
</xsl:stylesheet>
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
46.875ms