xsl-mode属性用法
本文出自 “熔 岩” 博客,出处http://lavasoft.blog.51cto.com/62575/60517
对某一个元素做多次处理,那么选择<xsl:apply-template元素处理。
如果要每次对同一个元素处理输出不同的结果,那么就需要使用mode属性。
<xsl:template>和<xsl:apply-templates>都有一个mode属性,只有在这两个元素里面同时设定了mode属性,并且属性值相同,那么模板规则才会匹配。
<?xml-stylesheet type="text/xsl" href="employees.xsl"?>
<!--这是公司雇员的信息-->
<employees>
<employee sn="E-200402100001">
<name>zhangsan</name>
<age>25</age>
<!--月薪小于等于2000元的雇员工资,以现金方式发放-->
<monthly_pay mode="cash">
1200.00
</monthly_pay>
</employee>
<employee sn="E-200402100006">
<name>lisi</name>
<age>28</age>
<monthly_pay mode="cash">
1600.00
</monthly_pay>
</employee>
<employee sn="E-200503220001">
<name>wangwu</name>
<age>30</age>
<!--月薪高于2000元的雇员工资,以信用卡转帐的方式发放-->
<monthly_pay mode="credit_card">
3500.00
</monthly_pay>
</employee>
</employees>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<table border="1">
<xsl:apply-templates select="employees/employee" mode="table"/>
</table>
<xsl:apply-templates select="employees/employee" mode="list"/>
</xsl:template>
<xsl:template match="employee" mode="table">
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="age"/></td>
<td><xsl:value-of select="monthly_pay"/></td>
</tr>
</xsl:template>
<xsl:template match="employee" mode="list">
<ul>
<li><xsl:value-of select="name"/></li>
<li><xsl:value-of select="age"/></li>
<li><xsl:value-of select="monthly_pay"/></li>
</ul>
</xsl:template>
</xsl:stylesheet>
<tr>
<td>zhangsan</td>
<td>25</td>
<td>1200.00</td>
</tr>
<tr>
<td>lisi</td>
<td>28</td>
<td>1600.00</td>
</tr>
<tr>
<td>wangwu</td>
<td>30</td>
<td>3500.00</td>
</tr>
</table>
<ul>
<li>zhangsan</li>
<li>25</li>
<li>1200.00</li>
</ul>
<ul>
<li>lisi</li>
<li>28</li>
<li>1600.00</li>
</ul>
<ul>
<li>wangwu</li>
<li>30</li>
<li>3500.00</li>
</ul>

xsl-mode属性用法的更多相关文章
- JS中Array数组的三大属性用法
原文:JS中Array数组的三大属性用法 Array数组主要有3大属性,它们分别是length属性.prototype属性和constructor属性. JS操作Array数组的方法及属性 本文总结了 ...
- js原生之scrollTop、offsetHeight和offsetTop等属性用法详解
scrollTop.offsetHeight和offsetTop等属性用法详解:标题中的几个相关相关属性在网页中有这大量的应用,尤其是在运动框架中,但是由于有些属性相互之间的概念比较混杂或者浏览器兼容 ...
- Android - include属性用法
include属性用法 本文地址: http://blog.csdn.net/caroline_wendy Android的layout中, 能够使用include属性样式, 这样能够把不同的layo ...
- css文本属性用法总结
稍稍总结了下css文本的一些属性用法,自己忘记的时候也可以用来查查,不用去查网站那么麻烦. 下面是部分总结,也希望对其他人有用 文本修饰 (1)text-decoration: 文本修饰(横线) 4 ...
- scrollTop、offsetHeight和offsetTop等属性用法详解--转转转
scrollTop.offsetHeight和offsetTop等属性用法详解: 标题中的几个相关相关属性在网页中有这大量的应用,尤其是在运动框架中,但是由于有些属性相互之间的概念比较混杂或者浏览器兼 ...
- 跨平台移动开发 Xuijs超轻量级的框架Style CSS属性用法
PhoneGap里面推荐使用的超轻量级的框架 Style CSS属性用法 设置css属性:setstyle 通过ID设置css属性 x$('#top1').setStyle('color', '#DB ...
- WPF Visibility属性用法
WPF Visibility属性用法 Visible 元素在窗体中正常显示 Collaspsed 元素不显示,也不占用空间 Hidden 元素不显示,但是任然为它保留空间
- godot新手教程1[button信号使用]<godot节点信号对照及节点属性用法>
button(按钮)节点信号对照: 1:pressed() #按钮点击信号 #绑定按钮点击后触发信号 Pressed使用案例: func _on_”节点路径”_Button_pressed( ...
- HTML5 <a>标签的ping属性用法
随着移动互联网用户井喷式的增长,web前端开发中的HTML5在近几年备受瞩目,越来越多的人从事html5开发相关工作.今天小编也来凑个热闹,和大家一起来谈谈HTML5中<a>标签的ping ...
随机推荐
- WCF 服务编程 - 常用绑定
WCF 定义了5中常用的绑定. 一. 绑定 1.基本绑定: 对应于BasicHttpBinding类.基本绑定能够将WCF服务公开为传统的ASMX Web服务,使得原客户端能够与新的服务协作.如果客 ...
- Linux学习之五--常用操作
文件操作: rm命令 删除文件夹实例:rm -rf /var/log/httpd/access将会删除/var/log/httpd/access目录以及其下所有文件.文件夹 2 删除文件使用实例:rm ...
- C# HttpWebReqeust和HttpWebResponse发送请求
var request = (HttpWebRequest)WebRequest.Create("URL"); var data = Encoding.UTF8.GetBytes( ...
- 解决 release-stripped.ap_' specified for property 'resourceFile' does not exist.
设置buildTypes里的release的shrinkResources为false即可,如果是 release-stripped.ap_' specified for property 'reso ...
- PhotoSwipe插件的使用
1.首先引入插件 <link rel="stylesheet" href="css/photoswipe.css"> <link rel=&q ...
- python之路二十一
URL - 两个 Views - 请求的其他信息 from django.core.handlers.wsgi import WSGIRequest ...
- 【openStack】Libcloud 如何支持 keystone V3?
Examples This section includes some examples which show how to use the newly available functionality ...
- Ubuntu 12.04 安装 Apache2+PHP5+MySQL
LAMP是Linux web服务器组合套装的缩写,分别是Apache+MySQL+PHP.此教程教大家如何在Ubuntu 12.04 LTS server 上安装Apache2服务器,包括PHP5(m ...
- c#线程间操作无效: 从不是创建控件“textBox1”的线程访问它
线程开始前: Control.CheckForIllegalCrossThreadCalls = false;
- C#Linq技术中SelectMany(...)的内部实现推测
对于声明为:public static IEnumerable<TResult> SelectMany<TSource, TResult>(this IEnumerable&l ...