Using XML and XSLT, this is really starting to look and feel like a database.
Wouldn't it be interesting if we could filter out a specific bunch of records depending on an equation? Modifying the for-each command, this is actually possible!
A filter can understand four basic equations...
We will adjust the for-each command to filter out and display only the records showing ALL for the age_group values.
You can now view the XML page... XML Example 7
I know, it is a rather small example, but just imagine a huge list of movies are in there and only a few of them are labelled with the age_group value of All.
One very important thing to remember is that spelling, CaSe LeTtErInG, and spacing counts! To filter the results correctly, the parameter must match the values being looked at.
Wouldn't it be interesting if we could filter out a specific bunch of records depending on an equation? Modifying the for-each command, this is actually possible!
A filter can understand four basic equations...
= | is equal to |
!= | is not equal to |
< | is less than |
> | is greater than |
We will adjust the for-each command to filter out and display only the records showing ALL for the age_group values.
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<table border="1">
<xsl:for-each select="list_of_movies/movie[age_group='All']">
<tr>
<td> <xsl:value-of select="title"/> </td>
<td> <xsl:value-of select="age_group"/> </td>
<td> <xsl:value-of select="comments"/> </td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<table border="1">
<xsl:for-each select="list_of_movies/movie[age_group='All']">
<tr>
<td> <xsl:value-of select="title"/> </td>
<td> <xsl:value-of select="age_group"/> </td>
<td> <xsl:value-of select="comments"/> </td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
You can now view the XML page... XML Example 7
I know, it is a rather small example, but just imagine a huge list of movies are in there and only a few of them are labelled with the age_group value of All.
One very important thing to remember is that spelling, CaSe LeTtErInG, and spacing counts! To filter the results correctly, the parameter must match the values being looked at.
