I am trying to pull movies less than than a certain year and greater than a certain year. Im having issues with my output. This is my XSLT code
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="html" indent="yes"/>
<!-- defines the format of the style sheet (html) -->
<xsl:template match="/">
<!-- the match attribute is used to connect the template with the xml element match = "/" means match the whole document. -->
<html>
<head>
<title>Movie Listing</title>
<h1>My Favorite Movies From Before 2005</h1>
<style type="text/css">
table, tr, td, th{background-color:"powderblue"; border: 3px solid black; padding: 5px; border-spacing: 3px;) <!-- style for table -->
</style>
</head>
<body>
<table>
<tr>
<td>
<b>Movie ID</b>
</td>
<td>
<b>Title</b>
</td>
<td>
<b>Director</b>
</td>
<td>
<b>Year</b>
</td>
<td>
<b>Genres</b>
</td>
<xsl:apply-templates select ="movies/movie[year<2005]"></xsl:apply-templates>
<tr>
<td colspan ="3">
<b>Number of Movies</b>
</td>
<td colspan ="2">
<xsl:value-of select="count(movies/movie[year<2005])"/>
</td>
</tr>
</tr>
</table>
<ul>
<b>Principal Directors:</b>
<xsl:for-each select="movies/movie[year<2005]">
<xsl:sort select="pdirector" order="ascending"/>
<li>
<xsl:value-of select="pdirector"/>
</li>
</xsl:for-each>
</ul>
<h1>My Favorite Movies From 2005 Onward</h1>
<table>
<tr>
<td>
<b>Movie ID</b>
</td>
<td>
<b>Title</b>
</td>
<td>
<b>Director</b>
</td>
<td>
<b>Year</b>
</td>
<td>
<b>Genres</b>
</td>
<xsl:apply-templates select ="movies/movie[year>=2005]"></xsl:apply-templates>
<tr>
<td colspan ="3">
<b>Number of Movies</b>
</td>
<td colspan ="2">
<xsl:value-of select="count(movies/movie[year>=2005])"/>
</td>
</tr>
</tr>
</table>
<ul>
<b>Principal Directors:</b>
<xsl:for-each select="movies/movie[year>=2005]">
<xsl:sort select="pdirector" order="ascending"/>
<li>
<xsl:value-of select="pdirector"/>
</li>
</xsl:for-each>
</ul>
</body>
</html>
</xsl:template>
<xsl:template match="movies"> <!-- template for data -->
<xsl:for-each select ="movie"> <!-- looping through movie -->
<xsl:sort select="title" order="ascending"/> <!-- sorting through movie -->
<tr>
<td>
<xsl:value-of select ="@id"/>
<!-- grabbing id-->
<br></br>
</td>
<td>
<!-- grabbing title -->
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="url"/>
</xsl:attribute>
<xsl:value-of select="title"/>
</xsl:element>
<br></br>
</td>
<td>
<xsl:value-of select ="pdirector"/>
<!-- grabbing pdirector -->
<br></br>
</td>
<td>
<xsl:value-of select ="year"/>
<!-- grabing year -->
<br></br>
</td>
<td>
<xsl:for-each select ="genres">
<xsl:value-of select="genre"/>,
<xsl:value-of select="genre[2]"/>,
<xsl:value-of select="genre[3]"/>
<br></br>
</xsl:for-each>
</td>
</tr>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
The statements where I apply the actual templates seem to be giving me the issues because when I leave them empty and I just pull everything its formatted correctly.
<xsl:apply-templates></xsl:apply-templates>
When I go ahead and set a condition to pull the movies from, my output goes wrong
Code:
<xsl:apply-templates select="movies/movie[year<2005]"></xsl:apply-templates>
and
<xsl:apply-templates select="movies/movie[year>=2005]"></xsl:apply-templates>