<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="ISO-8859-1"/>
	
	
	<xsl:template match="reaction">
		<html>
			<head>
				<title>
	
					<xsl:value-of select="form"/>
	
				</title>
				<style type="text/css">
					* { 
						font-family: verdana;
						font-size: 9pt;
					}
					
					td.col_b, td.col_a, td.col_c {
						border-bottom: 1px solid #C0C0C0;
					}

					td.col_c, td.col_a {
						background-color: #DDDDDD;
						width: 35%;
						vertical-align: top;
						font-weight: bold;
					}
					
					td.col_a {
						border-right: 1px solid black; 
					}
					
				</style>
			</head>
			<body>
				<table width="100%" cellpadding="2" cellspacing="0" style="border: 1px solid black;">

					<xsl:apply-templates select="attributes"/>

				</table>
			</body>
		</html>
	
	</xsl:template>


	<xsl:template match="attributes">
		<xsl:for-each select="attribute">
			<tr>
				<xsl:if test="type='dsp'">
					<td colspan="2" class="col_c">
						<xsl:variable name="ResultTreeFragmentOut">
							<xsl:call-template name="lf2br">
								<xsl:with-param name="StringToTransform" select="label"/>
							</xsl:call-template>
						</xsl:variable>
						<xsl:copy-of select="$ResultTreeFragmentOut"/>
					</td>
				</xsl:if>
				<xsl:if test="type!='dsp'">
					<td class="col_a">
						<xsl:variable name="ResultTreeFragmentOut">
							<xsl:call-template name="lf2br">
								<xsl:with-param name="StringToTransform" select="label"/>
							</xsl:call-template>
						</xsl:variable>
						<xsl:copy-of select="$ResultTreeFragmentOut"/>
					</td>
					<td class="col_b">
						<xsl:variable name="ResultTreeFragmentOut2">
							<xsl:call-template name="lf2br">
								<xsl:with-param name="StringToTransform" select="answer"/>
							</xsl:call-template>
						</xsl:variable>
						<xsl:copy-of select="$ResultTreeFragmentOut2"/>
						<xsl:apply-templates select="answers"/>
					</td>
				</xsl:if>
			</tr>
		</xsl:for-each>
	</xsl:template>
	
	
	<xsl:template match="answers">
		<xsl:for-each select="answer">

			- <xsl:value-of select="text()"/><br/>

		</xsl:for-each>
	</xsl:template>
	

	<xsl:template name="lf2br">
		<!-- import $StringToTransform -->
		<xsl:param name="StringToTransform"/>
		<xsl:choose>
			<!-- string contains linefeed -->
			<xsl:when test="contains($StringToTransform,'&#10;')">
				<!-- output substring that comes before the first linefeed -->
				<!-- note: use of substring-before() function means        -->
				<!-- $StringToTransform will be treated as a string,       -->
				<!-- even if it is a node-set or result tree fragment.     -->
				<!-- So hopefully $StringToTransform is really a string!   -->
				<xsl:value-of select="substring-before($StringToTransform,'&#10;')"/>
				<!-- by putting a 'br' element in the result tree instead  -->
				<!-- of the linefeed character, a <br> will be output at   -->
				<!-- that point in the HTML                                -->
				<br/>
				<!-- repeat for the remainder of the original string -->
				<xsl:call-template name="lf2br">
					<xsl:with-param name="StringToTransform">
						<xsl:value-of select="substring-after($StringToTransform,'&#10;')"/>
					</xsl:with-param>
				</xsl:call-template>
			</xsl:when>
			<!-- string does not contain newline, so just output it -->
			<xsl:otherwise>
				<xsl:value-of select="$StringToTransform"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="text()"/>

</xsl:stylesheet>
