Listing of xtf-HTML.xsl
<?xml version='1.0'?>
<!--
-->
<xsl:stylesheet version="1.0"
xmlns:xtf="http://emegir.info/xtf/2"
xmlns:xcl="http://emegir.info/xcl/1"
xmlns:xff="http://emegir.info/xff/1"
xmlns:xtr="http://emegir.info/xtr"
xmlns:gdl="http://emegir.info/gdl"
xmlns:norm="http://emegir.info/norm"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
xmlns:md="http://emegir.info/xmd/1"
xmlns:xh="http://www.w3.org/1999/xhtml"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="xcl xff xtf gdl md xtr norm"
extension-element-prefixes="exsl">
<xsl:import href="xtf1-HTML.xsl"/>
<xsl:import href="gdl-HTML.xsl"/>
<!---->
<!---->
<xsl:include href="escape-quotes.xsl"/>
<xsl:output method="xml" indent="yes" encoding="utf-8"/>
<!---->
<xsl:variable name="lc" select="'abcdefghijklmnopqrstuvwxyzšŋ'"/>
<xsl:variable name="uc" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZŠŊ'"/>
<!---->
<xsl:key name="label" match="xtf:object|xtf:surface|xtf:column|xtf:l" use="@label"/>
<xsl:variable name="PQ-id">
<xsl:choose>
<xsl:when test="not(/*/@xml:id) and /*/@ref">
<xsl:value-of select="/*/@ref"/>
</xsl:when>
<xsl:when test="starts-with(/*/@xml:id,'s.')">
<xsl:value-of select="substring-after(/*/@xml:id,'s.')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="/*/@xml:id"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="xmd" select="concat($PQ-id,'.xmd')"/>
<xsl:variable name="pubimg">
<xsl:if test="document($xmd,/)/*/md:public_images='yes'">
<xsl:choose>
<xsl:when test="/*/md:images/md:img[@type='p']">
<!---->
<xsl:text>**</xsl:text>
</xsl:when>
<xsl:when test="/*/md:images/md:img[@type='l']">
<!---->
<xsl:text>*</xsl:text>
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
</xsl:if>
</xsl:variable>
<!--
-->
<xsl:template match="xtf:xtf">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="xtr:translation"/>
<xsl:template name="base-attr">
<xsl:copy-of select="@n|@xml:id|@cols"/>
<xsl:attribute name="xlabel">
<xsl:value-of select="concat($pubimg,@n)"/>
</xsl:attribute>
</xsl:template>
<xsl:template match="xtf:transliteration">
<table class="transliteration">
<xsl:call-template name="base-attr"/>
<xsl:apply-templates/>
</table>
</xsl:template>
<xsl:template match="atf">
<pre>
<xsl:value-of select="text()"/>
</pre>
</xsl:template>
<xsl:template match="xtf:refunit">
<xsl:apply-templates select="*"/>
</xsl:template>
<xsl:template match="xtf:composite">
<table class="composite">
<xsl:call-template name="base-attr"/>
<xsl:apply-templates/>
</table>
</xsl:template>
<xsl:template match="xtf:score">
<xsl:variable name="pid" select="substring-after(/*/@xml:id,'s.')"/>
<score n="{@n}">
<xsl:for-each select="xtf:lg">
<table block-id="{@n}" class="score-block">
<xsl:call-template name="base-attr"/>
<xsl:apply-templates/>
</table>
</xsl:for-each>
</score>
</xsl:template>
<xsl:template match="xtf:m">
<tr class="h1">
<td colspan="10">
<span class="div">
<xsl:choose>
<xsl:when test="@subtype = 'column'">
<xsl:value-of select="concat('(column ',text(),')')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of
select="concat('(',@subtype|@division|text(),')')"/>
</xsl:otherwise>
</xsl:choose>
</span>
</td>
</tr>
</xsl:template>
<xsl:template match="xtf:div">
<xsl:if test="not(@type='segment') or not(@n='0')">
<tr class="h1">
<td colspan="10">
<xsl:variable name="itype">
<xsl:call-template name="init-cap">
<xsl:with-param name="str" select="@subtype|@type"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="n">
<xsl:if test="@n">
<xsl:value-of select="concat(' ',@n)"/>
</xsl:if>
</xsl:variable>
<span class="div"><xsl:value-of select="concat($itype,$n)"/></span>
</td>
</tr>
</xsl:if>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="xtf:referto">
<xsl:if test="preceding-sibling::*[1][not(local-name()='referto')]">
<tr class="h1"><td colspan="10">See Also</td></tr>
</xsl:if>
<tr class="referto">
<td colspan="10">
<a href="/cgi-bin/cdlhtml?mode=ctxt&item={@ref}"><xsl:value-of select="@n"/></a>
</td>
</tr>
</xsl:template>
<xsl:template match="xtf:include">
<xsl:variable name="refproject">
<xsl:choose>
<xsl:when test="contains(@ref,'/')">
<xsl:value-of select="substring-before(@ref,'/')"/>
</xsl:when>
<xsl:otherwise>
<xsl:text/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="refid">
<xsl:choose>
<xsl:when test="contains(@ref,'/')">
<xsl:value-of select="substring-after(@ref,'/')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@ref"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="basename">
<xsl:text>/usr/local/share/cdl/texts/</xsl:text>
<xsl:value-of select="substring($refid,1,4)"/>
<xsl:text>/</xsl:text>
<xsl:value-of select="$refid"/>
<xsl:if test="string-length($refproject) > 0">
<xsl:text>/</xsl:text>
<xsl:value-of select="$refproject"/>
<xsl:text>/</xsl:text>
</xsl:if>
<xsl:value-of select="$refid"/>
</xsl:variable>
<xsl:variable name="refdoc">
<xsl:value-of select="concat($basename,'.xtf')"/>
</xsl:variable>
<xsl:variable name="incdoc">
<xsl:value-of select="concat($basename,'.txh')"/>
</xsl:variable>
<tr class="h2">
<td colspan="10">
<a href="javascript:showexemplar('{$refproject}','{$refid}','','')"><xsl:value-of select="@n"/></a>
</td>
</tr>
<xsl:choose>
<xsl:when test="@from">
<xsl:variable name="f" select="@from"/>
<xsl:variable name="start-id">
<xsl:for-each select="document($refdoc)/*">
<xsl:value-of select="key('label',$f)/@xml:id"/>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="end-id">
<xsl:choose>
<xsl:when test="@to">
<xsl:for-each select="document($refdoc)/*">
<xsl:value-of select="key('label',$f)/@xml:id"/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="document($refdoc)">
<xsl:for-each select="id($start-id)">
<xsl:value-of select=".//xtf:l[last()]/@xml:id"/>
</xsl:for-each>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!--
-->
<xsl:for-each select="document($incdoc)">
<xsl:for-each select="id($start-id)">
<xsl:call-template name="copy-until">
<xsl:with-param name="next" select="."/>
<xsl:with-param name="end" select="$end-id"/>
</xsl:call-template>
</xsl:for-each>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:message>including <xsl:value-of select="$incdoc"/></xsl:message>
<xsl:copy-of select="document($incdoc)/*/*"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="copy-until">
<xsl:param name="next"/>
<xsl:param name="end"/>
<xsl:copy-of select="$next"/>
<!--
-->
<xsl:choose>
<xsl:when test="$next/@xml:id = $end"/>
<xsl:otherwise>
<xsl:call-template name="copy-until">
<xsl:with-param name="next" select="$next/following-sibling::*[1]"/>
<xsl:with-param name="end" select="$end"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="xtf:object">
<xsl:if test="not(@type='tablet') or @n">
<xsl:variable name="hclass">
<xsl:choose>
<xsl:when test="@type='envelope'">hforce</xsl:when>
<xsl:otherwise>h</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<tr class="{$hclass}">
<xsl:copy-of select="@xml:id"/>
<td colspan="10">
<span class="h2">
<xsl:variable name="object">
<xsl:choose>
<xsl:when test="@type='other'">
<xsl:value-of select="@object"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@type"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="not($object='tablet')">
<xsl:call-template name="init-cap">
<xsl:with-param name="str" select="$object"/>
</xsl:call-template>
<xsl:text> </xsl:text>
</xsl:if>
<xsl:choose>
<xsl:when test="@n">
<xsl:value-of select="@n"/>
</xsl:when>
<xsl:when test="@face">
<xsl:text> </xsl:text>
<xsl:value-of select="@face"/>
</xsl:when>
<xsl:when test="@type='other'"/>
<xsl:otherwise>
<!--
-->
</xsl:otherwise>
</xsl:choose>
<xsl:if test="@certain='n'">
<xsl:text>?</xsl:text>
</xsl:if>
</span>
</td>
</tr>
</xsl:if>
<xsl:choose>
<xsl:when test="xtf:l|xtf:lg/xtf:l">
<xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="xtf:surface|xtf:sealing">
<xsl:if test="ancestor::xtf:object[@type='tablet' or @type='envelope']
or @face
or @surface
or self::xtf:sealing">
<xsl:variable name="hclass">
<xsl:choose>
<xsl:when test="@type='seal'">hforce</xsl:when>
<xsl:otherwise>h</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<tr class="{$hclass}">
<xsl:copy-of select="@xml:id"/>
<td colspan="10">
<span class="h2">
<xsl:choose>
<xsl:when test="not(local-name()='surface')">
<xsl:call-template name="init-cap">
<xsl:with-param name="str" select="local-name()"/>
</xsl:call-template>
<xsl:text> </xsl:text>
</xsl:when>
<xsl:when test="@type='seal'">
<xsl:call-template name="init-cap">
<xsl:with-param name="str" select="@type"/>
</xsl:call-template>
<xsl:text> </xsl:text>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="@n">
<xsl:value-of select="@n"/>
</xsl:when>
<xsl:when test="@face">
<xsl:text> </xsl:text>
<xsl:value-of select="@face"/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="@type='obverse' or @type='reverse'">
<xsl:if test="ancestor::xtf:object[@type='tablet']">
<xsl:call-template name="init-cap">
<xsl:with-param name="str" select="@type"/>
</xsl:call-template>
</xsl:if>
</xsl:when>
<xsl:when test="@type='surface'">
<xsl:call-template name="init-cap">
<xsl:with-param name="str" select="@surface"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="init-cap">
<xsl:with-param name="str" select="@type"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="@certain='n'">
<xsl:text>?</xsl:text>
</xsl:if>
</span>
</td>
</tr>
</xsl:if>
<xsl:choose>
<xsl:when test="xtf:l|xtf:lg/xtf:l">
<xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="xtf:column">
<xsl:if test="not(@n = '0')">
<tr class="h">
<xsl:copy-of select="@xml:id"/>
<td colspan="10">
<span class="h2">
<xsl:call-template name="init-cap">
<xsl:with-param name="str" select="local-name()"/>
</xsl:call-template>
<xsl:text> </xsl:text>
<xsl:variable name="n"
select="document('label-info.xml')/*/*[@n=current()/@n]/@a"/>
<xsl:choose>
<xsl:when test="string-length($n) > 0">
<xsl:value-of select="$n"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@n"/>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="@primes"><xsl:value-of select="@primes"/></xsl:if>
<xsl:if test="@remark='y'"><xsl:text>!</xsl:text></xsl:if>
<xsl:if test="@certain='n'"><xsl:text>?</xsl:text></xsl:if>
</span>
</td>
</tr>
</xsl:if>
<xsl:choose>
<xsl:when test="*[xtf:c]|xtf:lg/*[xtf:c]">
<xsl:variable name="maxcols">
<xsl:for-each select="*[xtf:c]|*/*[xtf:c]">
<xsl:sort select="count(xtf:c)" order="descending"/>
<xsl:if test="position() = 1">
<xsl:value-of select="count(xtf:c)"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<!---->
<xsl:apply-templates>
<xsl:with-param name="maxcols" select="$maxcols"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="xtf:lg">
<xsl:param name="maxcols" select="0"/>
<xsl:apply-templates>
<xsl:with-param name="maxcols" select="$maxcols"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="xtf:noncolumn">
<tr class="noncolumn">
<td colspan="10"><xsl:call-template name="do-non-c-or-l"/></td>
</tr>
</xsl:template>
<xsl:template match="xtf:nonl|xtf:nonx">
<xsl:variable name="xnonl-class">
<xsl:choose>
<xsl:when test="preceding-sibling::*[1][self::xtf:nonl or self::xtf:nonx]">
<xsl:choose>
<xsl:when test="following-sibling::*[1][self::xtf:nonl or self::xtf:nonx]">
<xsl:text>-medial</xsl:text>
</xsl:when>
<xsl:otherwise>-final</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="following-sibling::*[1][self::xtf:nonl or self::xtf:nonx]">
<xsl:text>-initial</xsl:text>
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
</xsl:variable>
<tr class="nonl{$xnonl-class}">
<xsl:if test="@xml:id">
<xsl:attribute name="xml:id">
<xsl:value-of select="@xml:id"/>
</xsl:attribute>
</xsl:if>
<xsl:choose>
<xsl:when test="not(preceding-sibling::*[1])">
<td class="lnum">
<span class="xlabel">
<xsl:value-of select="translate(ancestor-or-self::*[@label][1]/@label,
' ',' ')"/>
</span>
<span class="lnum">
<xsl:value-of select="@n"/><xsl:text>.</xsl:text>
</span>
</td>
</xsl:when>
<xsl:otherwise>
<td class="nonlnum"> </td>
</xsl:otherwise>
</xsl:choose>
<td colspan="1" class="nonlbody"><xsl:call-template name="do-non-c-or-l"/></td>
</tr>
</xsl:template>
<xsl:template name="do-non-c-or-l">
<span class="noncl">
<xsl:choose>
<xsl:when test="@strict=1">
<xsl:if test="not(@state='ruling')">
<xsl:text> (</xsl:text>
</xsl:if>
<xsl:choose>
<xsl:when test="@scope='impression' and not(starts-with(.,'('))">
<xsl:value-of select="concat('impression of ',.)"/>
</xsl:when>
<xsl:when test="@extent='0' or @extent='n'">
<xsl:value-of select="@state"/>
</xsl:when>
<xsl:when test="@state='ruling'">
<hr width="200px" align="left"/>
</xsl:when>
<xsl:otherwise>
<xsl:if test="@state='traces'">
<xsl:text>traces</xsl:text>
<xsl:if test="@extent"><xsl:text> of </xsl:text></xsl:if>
</xsl:if>
<xsl:if test="@extent and not(@scope='impression')">
<xsl:value-of select="@extent"/>
<xsl:text> </xsl:text>
<xsl:if test="@extent = 'rest' or @extent = 'start'">
<xsl:text>of </xsl:text>
</xsl:if>
</xsl:if>
<xsl:if test="not(@state='seal') and not(@state='ruling') and @extent">
<xsl:value-of select="@scope"/>
<xsl:if test="@extent='n' or @extent>1"><xsl:text>s</xsl:text></xsl:if>
<xsl:if test="not(@state='traces')"><xsl:text> </xsl:text></xsl:if>
</xsl:if>
<xsl:if test="not(@state='traces')">
<xsl:value-of select="@state"/>
</xsl:if>
<xsl:if test="@ref">
<xsl:text> </xsl:text>
<xsl:value-of select="@ref"/>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="not(@state='ruling')">
<xsl:text>)</xsl:text>
</xsl:if>
</xsl:when>
<xsl:when test="@type='image'">
<img src="/{ancestor::xtf:transliteration/@project}/images/{@ref}.png"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</span>
</xsl:template>
<xsl:template match="xtf:nong">
<span class="nong">
<xsl:choose>
<xsl:when test="@type='broken'">
<!--
-->
<xsl:text> [...] </xsl:text>
</xsl:when>
<xsl:when test="@type='maybe-broken'">
<xsl:text> [(...)] </xsl:text>
</xsl:when>
<xsl:when test="@type='traces'">
<xsl:text> (</xsl:text>
<xsl:value-of select="@type"/>
<xsl:text> of </xsl:text>
<xsl:value-of select="@extent"/>
<xsl:text> signs)</xsl:text>
</xsl:when>
<!--
-->
<xsl:when test="@type='maybe-traces'">
<xsl:text> (...) </xsl:text>
</xsl:when>
<xsl:when test="@type='gap'">
<xsl:text> (</xsl:text>
<xsl:value-of select="@type"/>
<xsl:text> of </xsl:text>
<xsl:value-of select="@extent"/>
<xsl:text> signs)</xsl:text>
</xsl:when>
<xsl:when test="@type='other'">
<xsl:text> (</xsl:text>
<xsl:value-of select="text()"/>
<xsl:text>)</xsl:text>
</xsl:when>
<xsl:when test="@type='seal'">
<xsl:text> (seal </xsl:text>
<xsl:value-of select="@ref"/>
<xsl:text>)</xsl:text>
</xsl:when>
<xsl:when test="@type='newline'">
<xsl:text>;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:message><xsl:value-of
select="/*/@xml:id"/>: NONG type not handled: <xsl:value-of
select="@type"/></xsl:message>
</xsl:otherwise>
</xsl:choose>
</span>
</xsl:template>
<xsl:template match="xtf:l">
<xsl:param name="maxcols" select="0"/>
<xsl:variable name="href">
<xsl:choose>
<xsl:when test="/xtf:composite">
<xsl:value-of select="/*/@xml:id"/>
<xsl:text>_</xsl:text>
<xsl:value-of select="@n"/>
<xsl:text>.html</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="name">
<xsl:if test="/xtf:transliteration">
<xsl:value-of select="@xml:id"/>
</xsl:if>
</xsl:variable>
<!--
-->
<xsl:call-template name="format-line">
<xsl:with-param name="lnode" select="."/>
<xsl:with-param name="href" select="$href"/>
<xsl:with-param name="name" select="$name"/>
<xsl:with-param name="maxcols" select="$maxcols"/>
</xsl:call-template>
<xsl:apply-templates mode="after-line" select="xtf:note"/>
<!--
-->
</xsl:template>
<xsl:template name="format-line">
<xsl:param name="href"/>
<xsl:param name="lnode"/>
<xsl:param name="name"/>
<xsl:param name="maxcols"/>
<xsl:for-each select="$lnode">
<tr class="l">
<!--NOTE: XHTML 1.0 DOES NOT USE XML:ID, this needs to be hacked on output
uses the TXH files to return line context-->
<xsl:variable name="lid">
<xsl:choose>
<xsl:when test="self::xtf:mpx">
<xsl:value-of select="../@xml:id"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@xml:id"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="label">
<xsl:choose>
<xsl:when test="self::xtf:mpx">
<xsl:value-of select="../@label"/>
</xsl:when>
<xsl:when test="not(@label)">
<xsl:value-of select="@n"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="translate(@label,' ',' ')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="lnum">
<xsl:choose>
<xsl:when test="self::xtf:mpx">
<xsl:value-of select="../@n"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@n"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="string-length($lid)>0">
<xsl:attribute name="xml:id">
<xsl:value-of select="$lid"/>
</xsl:attribute>
</xsl:if>
<xsl:attribute name="label">
<xsl:value-of select="concat(/*/@n,', ',$label)"/>
</xsl:attribute>
<xsl:if test="count(preceding::xtf:l) > 5">
<xsl:attribute name="cid">
<xsl:value-of select="preceding::xtf:l[5]/@xml:id"/>
</xsl:attribute>
</xsl:if>
<xsl:choose>
<xsl:when test="string-length($href) > 0">
<td class="lnum">
<xsl:choose>
<xsl:when test="@xml:id">
<a name="a.{@xml:id}">
<span class="xlabel">
<xsl:value-of select="$label"/>
</span>
<span class="lnum">
<xsl:value-of select="@n"/><xsl:text>.</xsl:text>
</span>
</a>
</xsl:when>
<!---->
<xsl:otherwise/>
</xsl:choose>
</td>
<xsl:choose>
<xsl:when test="xtf:c">
<xsl:apply-templates>
<xsl:with-param name="maxcols" select="$maxcols"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<td><xsl:apply-templates/></td>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!---->
<xsl:when test="string-length($name) > 0">
<td class="lnum">
<a name="a.{$name}">
<span class="xlabel">
<!---->
<xsl:value-of select="$label"/>
</span>
<span class="lnum">
<xsl:value-of select="$lnum"/><xsl:text>.</xsl:text>
</span>
</a>
</td>
<xsl:choose>
<xsl:when test="xtf:c">
<xsl:apply-templates>
<xsl:with-param name="maxcols" select="$maxcols"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<td class="tlit"><p class="tt"><xsl:apply-templates/></p></td>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="/xtf:score">
<td class="lnum">
<span class="xlabel">
<xsl:value-of select="$label"/>
</span>
<span class="lnum">
<xsl:value-of select="@n"/><xsl:text>.</xsl:text>
</span>
<!---->
</td>
<xsl:choose>
<xsl:when test="xtf:c">
<xsl:apply-templates>
<xsl:with-param name="maxcols" select="$maxcols"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<td><xsl:apply-templates/></td>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<td class="lnum">
<span class="xlabel">
<xsl:value-of select="$label"/>
</span>
<span class="lnum">
<xsl:value-of select="@n"/><xsl:text>.</xsl:text>
</span>
<!---->
</td>
<xsl:choose>
<xsl:when test="xtf:c">
<xsl:apply-templates>
<xsl:with-param name="maxcols" select="$maxcols"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<td><xsl:apply-templates/></td>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</tr>
</xsl:for-each>
</xsl:template>
<xsl:template match="xtf:mpx"/>
<!---->
<xsl:template match="xtf:e">
<xsl:variable name="href">
<xsl:choose>
<xsl:when test="/xtf:score">
<xsl:value-of select="@p"/>
<xsl:text>.html#</xsl:text>
<xsl:value-of select="@plid"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<tr class="e">
<xsl:choose>
<xsl:when test="string-length($href) > 0">
<td> </td>
<xsl:choose>
<xsl:when test="xtf:c">
<xsl:apply-templates>
<xsl:with-param name="maxcols" select="$maxcols"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<td><xsl:apply-templates/></td>
</xsl:otherwise>
</xsl:choose>
<td><span class="enum">
<a href="javascript:showexemplar('{@p}','{@hlid}')">
<xsl:value-of select="concat(@n,' ',@l)"/>
</a></span>
</td>
</xsl:when>
<xsl:otherwise>
<td><span class="enum"><xsl:value-of select="concat(@n,' ',@l)"
/><xsl:text>. </xsl:text></span></td>
<xsl:choose>
<xsl:when test="xtf:c">
<xsl:apply-templates>
<xsl:with-param name="maxcols" select="$maxcols"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<td><xsl:apply-templates/></td>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</tr>
</xsl:template>
<xsl:template name="format-e">
</xsl:template>
<!--
-->
<xsl:template match="xtf:c">
<xsl:param name="maxcols"/>
<td class="c">
<xsl:if test="position() = last()">
<xsl:variable name="colspan"
select="$maxcols - (1+count(preceding-sibling::xtf:c))"/>
<xsl:if test="$colspan > 0">
<xsl:attribute name="colspan">
<xsl:value-of select="1+$colspan"/>
</xsl:attribute>
</xsl:if>
</xsl:if>
<p><xsl:apply-templates/></p>
</td>
</xsl:template>
<xsl:template match="xtf:f">
<xsl:choose>
<xsl:when test="@type='sv'">
<xsl:if test="*">
<xsl:apply-templates select=".//gdl:nonw"/>
<span class="{@type}">
<xsl:text> [[</xsl:text>
<xsl:apply-templates select="*[not(self::gdl:nonw)]">
<xsl:with-param name="allow-space" select="false()"/>
</xsl:apply-templates>
<xsl:text>]]</xsl:text>
</span>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<span class="{@type}">
<xsl:apply-templates/>
</span>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="following-sibling::*">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="norm:w">
<xsl:param name="allow-space" select="true()"/>
<xsl:call-template name="gdl-w">
<xsl:with-param name="allow-space" select="$allow-space"/>
</xsl:call-template>
</xsl:template>
<xsl:template mode="form" match="xtf:g">
<xsl:if test="not(@sign='ed.removed')">
<xsl:if test="@gloss"><xsl:text>{</xsl:text></xsl:if>
<xsl:choose>
<xsl:when test="@role='logogram'">
<xsl:call-template name="render-grapheme">
<xsl:with-param name="g" select="."/>
<xsl:with-param name="c" select="'logogram'"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="render-grapheme">
<xsl:with-param name="g" select="."/>
<xsl:with-param name="c" select="@nametype"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="@gloss"><xsl:text>}</xsl:text></xsl:if>
</xsl:if>
</xsl:template>
<xsl:template match="xtf:gg">
<xsl:for-each select="*">
<xsl:apply-templates select="."/>
<xsl:if test="not(position() = last())
and not(@gloss='pre')
and not(following-sibling::*[1][@gloss='post'])">
<xsl:text>.</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template mode="form" match="xtf:cg|xtf:gg|xtf:nong|xtf:cg.g|xtf:cg.gg">
<xsl:apply-templates select="."/>
</xsl:template>
<xsl:template mode="form" match="xtf:igg">
<xsl:apply-templates mode="form" select="*[1]"/>
</xsl:template>
<xsl:template mode="form" match="xtf:gloss" />
<xsl:template match="xtf:igg">
<xsl:apply-templates mode="igg-interp" select="*[1]"/>
<xsl:text>(</xsl:text>
<xsl:apply-templates mode="igg-verbatim" select="*[2]"/>
<xsl:text>)</xsl:text>
<xsl:for-each select="descendant::xtf:g[position()=last()]">
<xsl:variable name="prev-g"
select="preceding::xtf:g[1][ancestor::xtf:l/@xml:id
= current()/ancestor::xtf:l/@xml:id]"/>
<xsl:variable name="next-g"
select="following::xtf:g[1][ancestor::xtf:l/@xml:id
= current()/ancestor::xtf:l/@xml:id]"/>
<xsl:call-template name="close-sign">
<xsl:with-param name="next-g" select="$next-g"/>
</xsl:call-template>
<xsl:call-template name="close-breakage">
<xsl:with-param name="next-g" select="$next-g"/>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<xsl:template mode="igg-interp" match="xtf:gg">
<xsl:for-each select="*">
<xsl:apply-templates select="."/>
<xsl:if test="not(position() = last())">
<xsl:text>:</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template mode="igg-verbatim" match="xtf:gg">
<xsl:for-each select="*">
<xsl:apply-templates select="."/>
<xsl:if test="not(position() = last())">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template mode="igg-verbatim" match="xtf:cg">
<xsl:for-each select="*">
<xsl:apply-templates select="."/>
</xsl:for-each>
</xsl:template>
<xsl:template match="xtf:cg">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="xtf:cg.g">
<xsl:call-template name="render-grapheme">
<xsl:with-param name="g" select="."/>
<xsl:with-param name="c" select="'signref'"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="xtf:cg.gg">
<xsl:text>(</xsl:text>
<xsl:for-each select="*">
<xsl:apply-templates select="."/>
<!--
-->
</xsl:for-each>
<xsl:text>)</xsl:text>
</xsl:template>
<xsl:template match="xtf:cg.rel">
<xsl:choose>
<xsl:when test="@c='adjacent'">
<xsl:text>.</xsl:text>
</xsl:when>
<xsl:when test="@c='ligatured'">
<xsl:text>+</xsl:text>
</xsl:when>
<xsl:when test="@c='times'">
<xsl:text>×</xsl:text>
</xsl:when>
<xsl:when test="@c='over'">
<xsl:text>&</xsl:text>
</xsl:when>
<xsl:when test="@c='opposed'">
<xsl:text>@</xsl:text>
</xsl:when>
<xsl:when test="@c='crossed'">
<xsl:text>%</xsl:text>
</xsl:when>
<xsl:when test="@c='or'">
<xsl:text>/</xsl:text>
</xsl:when>
<xsl:when test="@c='exorder'">
<xsl:text>:</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:message>unknown cg.rel type '<xsl:value-of select="@c"/>'</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template mode="igg-interp" match="xtf:g|xtf:cg.g">
<xsl:apply-templates select="."/>
</xsl:template>
<xsl:template mode="igg-verbatim" match="xtf:g|xtf:cg.g">
<xsl:apply-templates select=".">
<xsl:with-param name="igg-verb" select="'yes'"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="xtf:gloss|gdl:gloss">
<xsl:if test="*|text()">
<sup class="gloss">
<xsl:apply-templates/>
</sup>
</xsl:if>
</xsl:template>
<xsl:template match="xtf:surro">
<xsl:apply-templates select="*[1]"/>
<xsl:text><(</xsl:text>
<xsl:apply-templates select="*[position()>1]"/>
<xsl:text>)> </xsl:text>
</xsl:template>
<xsl:template match="xtf:g">
<xsl:param name="igg-verb"/>
<xsl:choose>
<xsl:when test="@gloss">
<sup>
<xsl:if test="@gloss='post'
and preceding-sibling::*[1][local-name() = 'gloss']">
<xsl:text> </xsl:text>
</xsl:if>
<xsl:if test="@gloss='cont'
and preceding-sibling::xtf:g[@gloss='post']"
><xsl:text>-</xsl:text></xsl:if>
<xsl:call-template name="format-g"/>
<xsl:if test="@gloss='cont' and following-sibling::xtf:g[@gloss='pre']"
><xsl:text>-</xsl:text></xsl:if>
</sup>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="format-g">
<xsl:with-param name="igg-verb" select="$igg-verb"/>
</xsl:call-template>
<xsl:if test="(local-name(..)='l')
and not(position()=last())">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="format-g">
<xsl:param name="igg-verb"/>
<xsl:apply-templates select="."/>
</xsl:template>
<xsl:template match="xtf:cmt"/>
<xsl:template match="xtf:protocols|xtf:protocol"/>
<xsl:template match="xtf:*">
<xsl:variable name="loc"
select="ancestor::*[@xml:id][1]/@xml:id"/>
<xsl:message>xtf-HTML:<xsl:value-of select="$loc"
/> untrapped element <xsl:value-of
select="local-name()"/></xsl:message>
</xsl:template>
<!--
-->
<xsl:template name="init-cap">
<xsl:param name="str"/>
<xsl:value-of select="translate(substring($str,1,1),$lc,$uc)"/>
<xsl:value-of select="substring($str,2)"/>
</xsl:template>
<xsl:template match="xtf:note">
<xsl:choose>
<xsl:when test="ancestor::xtf:l"/>
<xsl:otherwise>
<p class="note">
<xsl:apply-templates/>
</p>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template mode="after-line" match="xtf:note">
<tr>
<td/>
<td colspan="10">
<span class="note"><xsl:text>???</xsl:text>
<xsl:text>(</xsl:text>
<xsl:apply-templates/>
<xsl:text>)</xsl:text>
</span>
</td>
</tr>
</xsl:template>
<xsl:template name="format-note">
<!-- <xsl:text>(</xsl:text>
-->
<span class="note"><xsl:apply-templates/></span>
<!--
-->
</xsl:template>
<!-- The content model of S has to be reviewed before it's worth
putting any real effort into this template -->
<xsl:template match="xtf:s">
<xsl:choose>
<xsl:when test="ancestor::xtf:l">
<xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
<tr>
<xsl:apply-templates/>
</tr>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!--
-->
<xsl:template match="xtf:lvg">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="xtf:wvg">
<xsl:text> {</xsl:text>
<xsl:for-each select="*">
<xsl:apply-templates/>
<xsl:if test="not(position()=last())">
<xsl:text> ; </xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:text>} </xsl:text>
</xsl:template>
<xsl:template match="xcl:xcl"/>
</xsl:stylesheet>