对xml模板 来说,name属性是很关键的 call-template /apply-template 的name必须要和模板的name相对应。模板相当于一个函数,可以暂时这么看。而name相当于函数名称.

简单说apply是应用,call是调用。    
用apply时,引擎自动搜索与当前select指定xpath的匹配节点相匹配的template(该template必须有属性match)并使用该template进行处理,此时需要指定的是select的path。 
用call时就跟其它语言调用函数一样,必须指定name属性,相应的,该template必须有name属性,当然,也可以在这时with-param(当然相应的模板中有对应的param才行,不过这个不强制要求)。

1)从名字区分:call-template,一次只对一个node名字有效;而apply-templates,注意是是复数,所以这个是对所有符合条件的node有效。
2)从手法上:call-template,手段是通过name;apply-templates手段是通过match。

3)使用apply调用的模板,   其中的上下文节点是与之匹配的节点。使用call调用的模板,   它没有上下文节点,参数通过param进行传递

call-template的用法

比如用到枚举型

定义

<xsl:call-template name="pollutionSource">
<xsl:with-param name="source" select="ns1:PollutionSource"></xsl:with-param>
</xsl:call-template>

实现

<xsl:template name="pollutionSource">
<xsl:param name="source" />
<xsl:if test="$source=0">
<xsl:text>水</xsl:text>
</xsl:if>
<xsl:if test="$source=1">
<xsl:text>气</xsl:text>
</xsl:if>
<xsl:if test="$source=2">
<xsl:text>生物</xsl:text>
</xsl:if>
<xsl:if test="$source=3">
<xsl:text>声</xsl:text>
</xsl:if>
</xsl:template>

call-template和apply-templates的更多相关文章

  1. springbooot2 thymeleaf 配置以及加载资源文件。Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration)

    最近在学习springbooot2 和 thymeleaf 程序文件 application.properties文件配置: #thymeleaf spring.thymeleaf.prefix=cl ...

  2. Package template (html/template) ... Types HTML, JS, URL, and others from content.go can carry safe content that is exempted from escaping. ... (*Template) Funcs ..

    https://godoc.org/text/template GoDoc Home About Go: text/templateIndex | Examples | Files | Directo ...

  3. Umbraco(2) - Creating Your First Template and Content Node(翻译文档)

    创建(编辑)你的第一个模板(Template) 展开 Settings > Templates文件夹 - 然后你应该看到子节点名为"Homepage" - 这是我们在创建Do ...

  4. C++11 : variadic templates(可变参数模板)

      Introduction: Before the possibilities of the new C++ language standard, C++11, the use of templat ...

  5. 3、Ansible playbooks(Hosts、Users、tasks、handlers、变量、条件测试(when、迭代)、templates)

    Ansible playbooks playbook是由一个或多个“play”组成的列表.play的主要功能在于将事先归并为一组的主机装扮成事先通过ansible中的task定义好的角色.从根本上来讲 ...

  6. IntelliJ IDEA 2017版 使用笔记(五) 模板 live template自定义设置(二) ;postfix使用;IDE快捷键使用

    一.live template 活模板     就像这个单词的含义一样,live template就是一个高效的提高代码,书写速度的方式,(live template位置File-----settin ...

  7. Rsyslog的模板template详解

    一. Template功能 根据用户需求指定任意格式 动态生成文件名 每个输出都使用了一些模板,包括针对文件的,针对用户消息等 备注: 旧版本:$template 新版本:template() V6之 ...

  8. angular—— Dynamic Templates

    原文:http://davidcai.github.io/blog/posts/router-dynamic-templates/ ui-router : templateProvider vs te ...

  9. 深入jvm虚拟机--第一篇 void TemplateInterpreterGenerator::generate_and_dispatch(Template* t, TosState tos_out) 函数

    今天第一次使用虚拟姐打断点,断点设置在了void TemplateInterpreterGenerator::generate_and_dispatch(Template* t, TosState t ...

  10. Deformable Templates For Eye Detection

    1 Abstract This approach was published On "Deformable Templates for Face Recognition" by A ...

随机推荐

  1. shell脚本中echo显示内容带颜色

    转自:http://www.cnblogs.com/lr-ting/archive/2013/02/28/2936792.html shell脚本中echo显示内容带颜色显示,echo显示带颜色,需要 ...

  2. asp.net,mvc4,mysql数据库,Ef遇到问题集合

    asp.net  mvc  mysql数据库,在我一个新手自学MVC4时遇到如下的问题,一一解决掉的方法记录如下方便自己日后查看,也为了方便一些像我一样的新手遇到如下问题时,提供参考 问题一: 解决办 ...

  3. 经验分享:CSS浮动(float,clear)通俗讲解(转载)

    很早以前就接触过CSS,但对于浮动始终非常迷惑,可能是自身理解能力差,也可能是没能遇到一篇通俗的教程. 前些天小菜终于搞懂了浮动的基本原理,迫不及待的分享给大家. 写在前面的话: 由于CSS内容比较多 ...

  4. Delphi 动态改变Rzsplitter的Orientation(方向)属性

    效果图: 原先不知道,弄了半天都改不了RzSplitter.Orientation = orHorizontal / orVertical 然后去查该组件的源代码,原来Orientation不是在Rz ...

  5. WebForm,Winfrom下拉框添加全部行

    WebForm: dropPostalLineNo.DataSource = "数据源";        dropPostalLineNo.DataTextField = &quo ...

  6. C# 部分关键字

    关键字: virtual:  虚方法,本身可以被实例化,也可以在派生类中重写该方法: override:在派生类重写基类虚方法时声明,避免了C++中的潜在运行错误: abstract:声明为抽象类.抽 ...

  7. Xcode7调试-b

    Xcode7中苹果为我们增加了两个重要的debug相关功能.了解之后觉得非常实用,介绍给大家. 1.Address Sanitizer: 妈妈再也不用担心 EXC_BAD_ACCESS? EXC_BA ...

  8. CentOS 6.x 下Postfix和dovecot邮件服务安装和基本配置

    1 卸载sendmail [root@mail~]# pstree | grep sendmail [root@mail~]# service sendmail stop [root@mail~]# ...

  9. Jest

    http://www.ibm.com/developerworks/cn/java/j-javadev2-24/

  10. pojShredding Company

    http://poj.org/problem?id=1416 #include<cstdio> #include<cstring> #define MAXN 100 using ...