XSL简明教程(6)XSL过滤和查询
点击次数:38 次 发布日期:2008-11-21 22:27:53 作者:源代码网
|
源代码网推荐源代码网整理以下原著:Jan Egil Refsnes 翻译:阿捷
源代码网整理以下六. 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>
源代码网整理以下你可以自己测试一下,看到的结果有什么不同。 源代码网供稿. |