Tutorial
Six. XSL filtering and querying
What should we do if we want to show only the XML data that satisfies certain criteria? Or the example code above, we just need to add parameters to the Select attribute of the Xsl:for-each element, like this:
<xsl:for-each select= "catalog/cd[artist= ' Bob Dylan '" >
The logical choices for parameters are:
= (equal To)
=! (Not equal to)
<& less than
>& greater than or equal
The same example as before (cd_catalog_sort.xsl):
<?xml version= ' 1.0 '?>
<xsl:stylesheet xmlns:xsl= "Http://www.w3.org/TR/WD-xsl" >
<xsl:template match= "/" >
<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>
</xsl:template>
</xsl:stylesheet>
You can test for yourself and see what the results are different.