以文本方式查看主题 - 中文XML论坛 - 专业的XML技术讨论区 (http://bbs.xml.org.cn/index.asp) -- 『 XSL/XSLT/XSL-FO/CSS 』 (http://bbs.xml.org.cn/list.asp?boardid=8) ---- [求助]<xsl:call-template>与<xsl:apply-templates>的区别是什么? (http://bbs.xml.org.cn/dispbbs.asp?boardid=8&rootid=&id=6677) |
-- 作者:sam -- 发布时间:4/12/2004 11:22:00 PM -- [求助]<xsl:call-template>与<xsl:apply-templates>的区别是什么? <xsl:call-template>一般用在什么地方? |
-- 作者:wedge -- 发布时间:4/13/2004 4:02:00 PM -- <xsl:call-template>能够建立模板函数,重复使用相同的模板元素,只需引入不同的参数就可以产生不同的结果! simplebook.xml ******************** <?xml version="1.0" encoding="GB2312"?> <?xml-stylesheet type="text/xsl" href="function.xslt"?> <!-- edited with XMLSPY v2004 rel. 3 U (http://www.xmlspy.com) by wedge (WWW) --> <!--网页制作彻底研究系列--> <booklist> <book sales="Y"> <code>F8915</code> <title>ASP网页制作彻底研究</title> <authorlist> <author>陈会安</author> <author>sun</author> </authorlist> <price>580</price> </book> <book sales="Y"> <code>F8916</code> <title>ASP与IIS 4/5网站架设彻底研究</title> <authorlist> <author>wedge</author> <author>sun</author> </authorlist> <price>550</price> </book> <book sales="N"> <code>F8917</code> <title>ASP精讲案例教程</title> <authorlist> <author>wedge</author> <author>sun</author> </authorlist> <price>590</price> </book> <book sales="N"> <code>F8918</code> <title> 家常小菜</title> <authorlist> <author>sally</author> <author>sun</author> </authorlist> <price>120</price> </book> </booklist> ******************** </table> </xsl:template> |
-- 作者:diegor -- 发布时间:4/13/2004 4:39:00 PM -- msxml 4.0 sdk say: The <xsl:call-template> enables you to invoke a named template—that is, an <xsl:template> element—that has an assigned name attribute. If an <xsl:template> element has a name attribute, it might, but need not, also have a match attribute. An <xsl:call-template> element invokes a template by name; it has a required name attribute that identifies the template to be invoked. Unlike <xsl:apply-templates>, <xsl:call-template> does not change the current node or the current node-list. An error occurs if a style sheet contains more than one template with the same name and with the same import precedence. <xsl:call-template The <xsl:apply-templates> element first selects a set of nodes using the expression specified in the select attribute. If this attribute is left unspecified, all children of the current node are selected. For each of the selected nodes, <xsl:apply-templates> directs the XSLT processor to find an appropriate <xsl:template> to apply. Templates are tested for applicability by comparing the node to the XPath expression specified in the template's match attribute. If more than one template satisfies the match pattern, the one appearing with the highest priority is chosen. If several templates have the same priority, the last in the style sheet is chosen. <xsl:apply-templates [此贴子已经被作者于2004-4-13 17:11:31编辑过]
|
-- 作者:sam -- 发布时间:4/14/2004 9:49:00 AM -- 谢谢wedge和diegor 找了很久的资料,看到了下面的东西,可惜还是搞不太明白 <xsl:apply-templates> Instructs the XSLT processor to apply the appropriate templates to a node-set. <xsl:call-template> Lets you invoke a particular template by name. This invocation is a convenient way to create commonly used output. For example, if you create an HTML page and all your HTML pages have the same masthead and footer, you could define templates named masthead and footer, then use <xsl:call-template> to invoke those templates as needed.
|
-- 作者:wedge -- 发布时间:4/15/2004 2:37:00 PM -- 当在xml中出现<xsl:apply-templates select="//book"/>时,应该跳出当前的模板,递归地去找符合 <xsl:templates select="book"/>的模板,把所有的book元素都显示出来,好象和递归计算n!的方法类似! |
-- 作者:KAI -- 发布时间:4/16/2004 6:18:00 PM -- call 你有name的template apply 你没有name 的template |
-- 作者:hyandlsz -- 发布时间:4/19/2004 10:55:00 AM -- 有道理! |
W 3 C h i n a ( since 2003 ) 旗 下 站 点 苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》 |
54.688ms |