<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
	<xsl:output method="html" encoding="UTF-8" indent="no"/>
	    <xsl:template match="format"/>
	    <xsl:template match="comments/item"/>
	    <xsl:template match="comments/itemdesc"/>
		
		<xsl:template match="/">
			<html>
				<body>
					<xsl:apply-templates mode="jw"></xsl:apply-templates>
					<p style="font-weight:normal;font-family:Arial;padding-left:4px;"><xsl:value-of select="//codes/@version"/></p>
					<table bgcolor="#ffffff" border="0" cellpadding="8" cellspacing="4" >
						<xsl:apply-templates/>
					</table>
				</body>
			</html>
		</xsl:template>
		<xsl:template match="codes/item">
			<xsl:variable name="itemcode"> 
				<xsl:value-of select="@code"/>
			</xsl:variable>				

			<tr style="font-weight:normal;font-family:Arial;font-size:small;">			
		
				<td style="background-color:#dddddf;width:200px;">
					<xsl:value-of select="@code"/>
				</td>
				<td style="background-color:#dddddf;max-width:400px;">
					<xsl:value-of select="@value"/>
				</td>
				<td style="background-color:#f1f1f1;max-width:400px;">
					<xsl:value-of select="."/>
				</td>
				
				<td style="max-width:400px;">
					<xsl:if test="@valid-to-version">
						<xsl:variable name="valid-to-version"> 
							<xsl:value-of select="@valid-to-version"/>
						</xsl:variable>				
						<div style="margin-top:-6px;color:#ff2222;padding:4px;">Not valid after version <xsl:value-of select="@valid-to-version"/> (<xsl:value-of select="//version[@number=$valid-to-version]/@expired"/>)</div>
					</xsl:if>


					<xsl:variable name="maxversion"> 
						<xsl:value-of select="//code-definition/versions/version[last()]/@number"/>
					</xsl:variable>				

					<xsl:if test="@valid-from-version=$maxversion and @valid-from-version!='1.0'">
						<xsl:variable name="valid-from-version"> 
							<xsl:value-of select="@valid-from-version"/>
						</xsl:variable>				
						<div style="margin-top:-6px;color:#2222ff;padding:4px;">NEW. Valid from version <xsl:value-of select="@valid-from-version"/> (<xsl:value-of select="//version[@number=$valid-from-version]/@valid-from"/>)<br/></div>
					</xsl:if>
					<div style="color:#7F7F7F;padding:4px;"><xsl:value-of select="//comments/item[@code=$itemcode]"/></div>
					<div style="color:#7F7F7F;padding:4px;"><xsl:value-of select="//comments/itemdesc[@code=$itemcode]"/></div>
				</td>
			</tr>
		</xsl:template>

		<xsl:template match="code-definition" mode="jw">
			<xsl:choose>			
				<xsl:when test="@element-name='sequence-type'">
					<font style="font-family:Arial;">
						<h2 style="padding:4px;">Sequence Type</h2>
						(Items listed in the order corresponding to the document matrix)
					</font>
				</xsl:when>	
				<xsl:when test="@element-name='sequence-description'"><h2 style="padding:4px;"><font style="font-family:Arial;">Sequence Description</font></h2></xsl:when>	
				<xsl:when test="@element-name='Sub-lead'"><h2 style="padding:4px;"><font style="font-family:Arial;">Submission Lead</font></h2></xsl:when>
				
			</xsl:choose>
		</xsl:template>
		
</xsl:stylesheet>
