<!-- 
XSL stylesheet to format TEI Lite XML documents' apparatus to HTML
Will work only for a parallel-segmentation type apparatus

Many ideas copied from the stylesheets for TEI lite XML written by 
Sebastian Rahtz.

--> 
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  version="1.0"
  xmlns:xt="http://www.jclark.com/xt"
  xmlns:saxon="http://icl.com/saxon"
  xmlns:lxslt="http://xml.apache.org/xslt"
  xmlns:xalan="org.apache.xalan.xslt.extensions.Xalan"
  extension-element-prefixes="saxon xt xalan">

<xsl:template name="bsv">
	<p>
		Legenda:<br/>
		<font color="red">Toevoegingen in rood</font><br/>
		<font color="blue">Verwijderingen in blauw</font><br/>
		<font color="brown">Wijzigingen in bruin</font><br/>
	</p>	
	<br/><br/>
	<center>
	<table border="0" cols="3" width="100%" >
		<xsl:for-each select="/TEI.2/text/body/div/div/div[starts-with(@id,'H')]" > 
			<tr><td width="6%"> </td>
			<td width="55%"><br/><br/><h3><xsl:value-of select="head"/></h3></td><td width="39%"> </td></tr>
			<tr><td width="6%"> </td><td width="55%" valign="top"><b>(Bruno)<br/></b></td><td width="39%" valign="top"><b>(Statenvertaling)</b></td></tr>
			<xsl:for-each select="lg" >
				<xsl:variable name="ident">
					<xsl:value-of select="concat('sv',substring-after(@id,'H'))"/>
				</xsl:variable>
				<tr><td width="6%" valign="top"><xsl:value-of select="head"/></td><td width="55%" valign="top">
				<xsl:for-each select="l" >  
					<xsl:apply-templates mode="bsv"/><br/>
				</xsl:for-each></td>
				<td width="39%" valign="top"><xsl:apply-templates select="//l[@id=$ident]" mode="bsv"/></td></tr>
			</xsl:for-each>  
		</xsl:for-each>  
	</table>
	</center>
</xsl:template>

<xsl:template match="seg" mode="bsv">
	<xsl:choose>
		<xsl:when test="contains(@ana,'SVCTU')">
			<font color="brown"> *<xsl:apply-templates mode="bsv"/>* </font>
		</xsl:when>
		<xsl:when test="contains(@ana,'SVCTI')">
			<font color="red"> *<xsl:apply-templates mode="bsv"/>* </font>
		</xsl:when>
		<xsl:when test="contains(@ana,'SVCTD')">
			<font color="blue"> *<xsl:apply-templates mode="bsv"/>* </font>
		</xsl:when>
	</xsl:choose>
</xsl:template>

<xsl:template match="note" mode="bsv">
</xsl:template>

<xsl:template match="*" mode="bsv">
	<xsl:apply-templates mode="bsv"/>
</xsl:template>

<xsl:template match="rdg" mode="bsv">
	<xsl:if test="contains(@wit,$preferredWitness)">
    	<xsl:apply-templates/>
    </xsl:if>
</xsl:template>

</xsl:stylesheet>


