XSL简明教程(6)XSL过滤和查询
2008-04-24 22:17
267 查看
六. XSL的过滤和查询如果我们希望只显示满足一定的条件的XML数据应该怎么做呢?还是上面的例子代码,我们只需要在XSL:for-each元素的select属性中加入参数就可以,类似:
<XSL:for-each select="CATALOG/CD[ARTIST='Bob Dylan']">
参数的逻辑选择有:
= (等于)
=! (不等于)
<& 小于
>& 大于等于
和前面同样的例子(cd_catalog_sort.XSL):
<?xml version='1.0'?>
<XSL:stylesheet xmlns:XSL="http://www.w3.org/TR/WD-XSL">
<XSL:template match="/">
<html>
<body>
<table border="2" bgcolor="yellow">
<tr>
<th>Title</th>
<th>Artist</th>
</tr>
<XSL:for-each select="CATALOG/CD[ARTIST='Bob Dylan']">
<tr>
<td><XSL:value-of select="TITLE"/></td>
<td><XSL:value-of select="ARTIST"/></td>
</tr>
</XSL:for-each>
</table>
</body>
</html>
</XSL:template>
</XSL:stylesheet>
你可以自己测试一下,看到的结果有什么不同。
<XSL:for-each select="CATALOG/CD[ARTIST='Bob Dylan']">
参数的逻辑选择有:
= (等于)
=! (不等于)
<& 小于
>& 大于等于
和前面同样的例子(cd_catalog_sort.XSL):
<?xml version='1.0'?>
<XSL:stylesheet xmlns:XSL="http://www.w3.org/TR/WD-XSL">
<XSL:template match="/">
<html>
<body>
<table border="2" bgcolor="yellow">
<tr>
<th>Title</th>
<th>Artist</th>
</tr>
<XSL:for-each select="CATALOG/CD[ARTIST='Bob Dylan']">
<tr>
<td><XSL:value-of select="TITLE"/></td>
<td><XSL:value-of select="ARTIST"/></td>
</tr>
</XSL:for-each>
</table>
</body>
</html>
</XSL:template>
</XSL:stylesheet>
你可以自己测试一下,看到的结果有什么不同。
相关文章推荐
- XSL简明教程(6)XSL过滤和查询
- XSL简明教程(6)XSL过滤和查询
- XSL简明教程(6)XSL过滤和查询
- XSL简明教程(6)XSL过滤和查询
- LINQ简明教程:数据排序、分组、过滤
- XSL简明教程(3)在客户端的实现
- XSL简明教程(3)在客户端的实现
- XSL简明教程
- 【Android 开发教程】条件查询、过滤和排序
- XSL简明教程(4)在服务器端的实现
- XSL简明教程(4)在服务器端的实现
- XSL简明教程(7)XSL 的控制语句
- XSL简明教程(5)XSL的索引
- XSL简明教程(7)XSL 的控制语句
- XSL简明教程(4)在服务器端的实现
- XSL简明教程
- XSL简明教程(4)在服务器端的实现
- XSL简明教程(1)XSL入门 (转载)
- XSL简明教程
- XSL简明教程(7)XSL 的控制语句