Is there a way to display rows that are older than 2 years from today in bold without repeating the code?
I know the condition I need, but I'm struggling with avoiding duplicating all the code just for a different style.
This is the code I have:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.x.org/1999/XSL/Transform">
<xsl:key name="albums-by-country" match="Album" use="Country" />
<xsl:template match="Albums">
<html>
<head>
<style>
h4 {
text-decoration: underline;
font-weight: bold;
}
</style>
</head>
<body>
<xsl:for-each select="Album[count(. | key('albums-by-country', Country)[1]) = 1]">
<xsl:sort select="Country" />
<h4 style="color:green;"><xsl:value-of select="Country" style="color:red;" /><br /></h4>
<table border="1">
<tr bgcolor="#979994">
<th style="text-align:left">Price</th>
<th style="text-align:left">Link</th>
<th style="text-align:left">Company</th>
<th style="text-align:left">Name</th>
<th style="text-align:left">Date</th>
<th style="text-align:left">Artist</th>
</tr>
<xsl:for-each select="key('albums-by-country', Country)">
<xsl:sort select="Date" />
<tr>
<td><xsl:value-of select="Price"/></td>
<td><xsl:value-of select="Link"/></td>
<td><xsl:value-of select="Company"/></td>
<td><xsl:value-of select="Name"/></td>
<xsl:choose>
<xsl:when test="string-length(Date)>4">
<td><xsl:value-of select="concat(substring(Date,5,2),'/',substring(Date,7,8),'/',substring(Date,1,4))"/></td>
</xsl:when>
<xsl:otherwise>
<td><xsl:value-of select="concat('01/01/',substring(Date,1,4))"/></td>
</xsl:otherwise>
</xsl:choose>
<td style="color:red;"><xsl:value-of select="Artist"/></td>
</tr>
</xsl:for-each>
<tr>
<td colspan="2">Total Amount</td>
<td bgcolor="#ffff00"><xsl:value-of select="sum(key('albums-by-country', Country)/Price)"/></td>
</tr>
</table>
<html>
<body>
</xsl:template>
</xsl:stylesheet>