Skip to content

Instantly share code, notes, and snippets.

@witoong623
Created December 2, 2016 15:18
Show Gist options
  • Save witoong623/cb3162a4538358727b143068f594d936 to your computer and use it in GitHub Desktop.
Save witoong623/cb3162a4538358727b143068f594d936 to your computer and use it in GitHub Desktop.
lab_w5 homework
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<style>
table,th, td {
border: 1px solid black;
}
</style>
</head>
<body>
<table>
<tr>
<th>title</th>
<th>artist</th>
<th>country</th>
<th>company</th>
<th>price</th>
<th>year</th>
</tr>
<xsl:for-each select="catalog/cd[year &lt; 1989 and year &gt; 1980]">
<xsl:sort select="artist"/>
<tr>
<td><xsl:value-of select="title"/></td>
<xsl:choose>
<xsl:when test="country = 'USA'">
<td bgcolor="#ff0000"><xsl:value-of select="artist"/></td>
<td bgcolor="#ff0000"><xsl:value-of select="country"/></td>
</xsl:when>
<xsl:when test="country = 'UK'">
<td bgcolor="#00ff00"><xsl:value-of select="artist"/></td>
<td bgcolor="#00ff00"><xsl:value-of select="country"/></td>
</xsl:when>
<xsl:otherwise>
<td><xsl:value-of select="artist"/></td>
<td><xsl:value-of select="country"/></td>
</xsl:otherwise>
</xsl:choose>
<td><xsl:value-of select="company"/></td>
<td style="text-align: right; width: 100px">$<xsl:value-of select="price"/></td>
<td><xsl:value-of select="year"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment