So I have a simple xml with some movies. I am trying to execute some xslt code to get it formatted to a table. Now the professor is insisting on using a for each loop for the genres which i find weird but ok. At any rate its the only thing i cant get to work I've reduced my code to bare bones please take a look and tell me where I am going wrong:
<?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"/> <xsl:template match="/"> <html><head></head><body> <table border="1" cellspacing="0" cellpadding="10"> <th style="background-color:lightgray">Title</th> <th style="background-color:lightgray">Director</th> <th style="background-color:lightgray">Genre</th> <xsl:for-each select="movies/movie"> <tr> <td> <xsl:value-of select"title"> </td> <td> <xsl:value-of select"director"> </td> <td> <xsl:for-each select="genre"> <xsl:value-of select="genre"/> </xsl:for-each> </td> </tr> </xsl:for-each> </table> </body></html></xsl:template> </xsl:stylesheet> And here is the xml:
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="Movies2.xslt"?> <movies> <!-- 1 --> <movie> <title>Schindler's List</title> <director>Steven Spielberg</director> <genre>Biography, </genre> <genre>Drama, </genre> <genre>History</genre> </movie> </movies>
No comments:
Post a Comment