<?xml version="1.0"?>
<!-- 
     Full view of Sikaiana dictionary
     G. Simons, SIL International (4 Jul 2005)
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
    <HTML>
      <HEAD>
        <TITLE>Sikaiana Dictionary</TITLE>
        <STYLE>
          BODY       { margin:30px; 
                       font-family: Arial, Helvetica, sans-serif;  }
          H1     { margin-left:-18px; }
          P      { text-indent:-18px; }
        </STYLE>
      </HEAD>

      <BODY>

          <H1>Sample entries from Sikaiana dictionary</H1>
          <xsl:apply-templates select="dictionary"/>

      </BODY>
    </HTML>
  </xsl:template>

	<xsl:template match="entry">
		<P>
				<B>
					<xsl:value-of select="form"/>
					<xsl:if test="@n">
						<SUP>
							<SMALL>
								<xsl:value-of select="@n"/>
							</SMALL>
						</SUP>
					</xsl:if>
				</B>
			<xsl:text>&#32;</xsl:text>
			<xsl:if test="etym">
(&lt; <xsl:value-of select="etym/lang"/>
				<xsl:text>&#32;</xsl:text>
				<xsl:value-of select="etym/mentioned"/>
				<xsl:if test="etym/gloss">
 '<xsl:value-of select="etym/gloss"/>'
           </xsl:if>) 
       </xsl:if>
			<xsl:apply-templates select="sense"/>
		</P>
	</xsl:template>
	<xsl:template match="sense">
		<xsl:if test="@n">
			<xsl:value-of select="@n"/>. </xsl:if>
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="gramGrp">[<I>
			<xsl:value-of select="pos"/>
		</I>
		<xsl:if test="gram">, <xsl:value-of select="gramGrp/gram"/>
		</xsl:if>] </xsl:template>
	<xsl:template match="def">
		<xsl:apply-templates/>. </xsl:template>
	<xsl:template match="eg">
		<I>
			<xsl:apply-templates select="q"/>
		</I>, '<xsl:apply-templates select="tr"/>'<xsl:choose>
			<xsl:when test="name(following-sibling::*[1]) = 'eg'">
				<xsl:text>; </xsl:text>
			</xsl:when>
			<xsl:otherwise>. </xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template match="note">
		<xsl:apply-templates/>&#32;</xsl:template>
	<xsl:template match="usg"> (<xsl:value-of select="."/>)   </xsl:template>
	<xsl:template match="reGrp">
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="re">
		<xsl:if test="@type">
			<xsl:call-template name="make-label">
				<xsl:with-param name="text">
					<xsl:value-of select="@type"/>
				</xsl:with-param>
			</xsl:call-template>
		</xsl:if>
		<I>
			<xsl:value-of select="form"/>
		</I>
		<xsl:if test="gramGrp"> [<xsl:value-of select="gramGrp/pos"/>
			<xsl:if test="gramGrp/gram">, <xsl:value-of select="gramGrp/gram"/>
			</xsl:if>] </xsl:if>
		<xsl:if test="def"> '<xsl:apply-templates select="def"/>'</xsl:if>
		<xsl:choose>
			<xsl:when test="following-sibling::re">, </xsl:when>
			<xsl:otherwise>. </xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template match="xr">
		<xsl:call-template name="make-label">
			<xsl:with-param name="text">
				<xsl:value-of select="@type"/>
			</xsl:with-param>
		</xsl:call-template>
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="ptr">
		<i>
			<a href="#{@target}">
				<xsl:choose>
					<xsl:when test="@form">
						<xsl:value-of select="@form"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="@target"/>
					</xsl:otherwise>
				</xsl:choose>
			</a>
		</i>
		<xsl:choose>
			<xsl:when test="following-sibling::ptr">, </xsl:when>
			<xsl:otherwise>. </xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template match="sik">
		<I>
			<xsl:apply-templates/>
		</I>
	</xsl:template>
	<xsl:template name="make-label">
		<xsl:param name="text"/>
		<xsl:value-of select="concat(translate(substring($text,1,1),'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'), substring($text,2),': ')"/>
	</xsl:template>
</xsl:stylesheet>

