<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="xml" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
        doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" encoding="UTF-8"/>
    <xsl:template match="xref"/>
    <xsl:template match="author"/>
    <xsl:template match="filename"/>
    <xsl:template match="encyclopedia"/>
    <xsl:template match="title">
        <xsl:choose>
            <xsl:when test="note or ling">
                <xsl:apply-templates/>
            </xsl:when>
            <xsl:otherwise/>
        </xsl:choose>
    </xsl:template>
    <xsl:template match="number"/>
    <xsl:template match="intro">
        <xsl:apply-templates select="ling | bookTitle/ling"/>
    </xsl:template>
    <xsl:template match="/">
        <html>
            <head>
                <title>Linguistic Notes</title>
                <meta http-equiv="Content-Type" content="application/xhtml+xml;charset=UTF-8"/>
                <link href="aa.css" rel="stylesheet" type="text/css"/>
            </head>
            <body>
                <h1>Linguistic Notes</h1>
                <xsl:apply-templates/>
            </body>
        </html>
    </xsl:template>
    <xsl:template match="tale | story | poem">
        <xsl:apply-templates/>
    </xsl:template>
    <xsl:template match="p">
        <xsl:apply-templates select="ling | note"/>
    </xsl:template>
    <xsl:template match="lg">
        <xsl:apply-templates/>
    </xsl:template>
    <xsl:template match="line">
        <xsl:apply-templates select="ling | note"/>
    </xsl:template>
    <xsl:template match="ling">
        <p>
            <xsl:apply-templates/>
        </p>
    </xsl:template>
    <xsl:template match="lingText">
        <xsl:variable name="temp">
            <xsl:text>ling</xsl:text>
            <xsl:number count="lingText" level="any"/>
        </xsl:variable>
        <xsl:variable name="temp1">
            <xsl:choose>
                <xsl:when test="/tale">
                    <xsl:text>a</xsl:text>
                    <xsl:value-of select="/tale/number"/>
                    <xsl:text>_text.html#ling</xsl:text>
                    <xsl:number count="lingText" level="any"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="/*/filename"/>
                    <xsl:text>_text.html#ling</xsl:text>
                    <xsl:number count="lingText" level="any"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <strong>
            <a name="{$temp}" href="{$temp1}" target="text">
                <xsl:apply-templates/>
            </a>
        </strong>
        <xsl:text> </xsl:text>
    </xsl:template>
    <xsl:template match="noteText">
        <xsl:apply-templates select="ling | line/ling"/>
    </xsl:template>
    <xsl:template match="noteExplanation"/>
    <xsl:template match="citation">
        <em>
            <xsl:apply-templates/>
        </em>
    </xsl:template>
    <xsl:template match="gloss">
        <xsl:text>&#x2018;</xsl:text>
        <xsl:apply-templates/>
        <xsl:text>&#x2019;</xsl:text>
    </xsl:template>
    <xsl:template match="quote">
        <xsl:text>&#x201C;</xsl:text>
        <xsl:apply-templates/>
        <xsl:text>&#x201D;</xsl:text>
    </xsl:template>
    <xsl:template match="emphasis">
        <em>
            <xsl:apply-templates/>
        </em>
    </xsl:template>
    <xsl:template match="url">
        <a href="{.}" target="_blank">
            <xsl:value-of select="."/>
        </a>
    </xsl:template>
    <xsl:template match="morphology">
        <em>
            <xsl:apply-templates/>
        </em>
    </xsl:template>
    <xsl:template match="note">
        <xsl:apply-templates/>
    </xsl:template>
</xsl:stylesheet>
