<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
        doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" indent="yes"/>
    <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" scope="stylesheet">
        <xd:desc>
            <xd:p><xd:b>Created on:</xd:b> April 1, 2010</xd:p>
            <xd:p><xd:b>Author:</xd:b>Nicole Dixon</xd:p>
            <xd:p/>
        </xd:desc>
    </xd:doc>

    <xsl:template match="/">
        <html>
            <head>
                <title>
                    <xsl:value-of select="mona/header/title"/>
                </title>
                <meta>
                    <xsl:attribute name="name">description</xsl:attribute>
                    <xsl:attribute name="content">
                        <xsl:value-of select="mona/header/description"/>
                    </xsl:attribute>
                </meta>
                <link type="text/css" rel="stylesheet" media="screen" href="mona.css"/>
                <link type="text/css" href="mona_print.css" rel="stylesheet" media="print"/>
            </head>
            <body>
                <div id="wrapper">

                    <!-- put contents here -->

                    <xsl:apply-templates select="mona"/>

                    <div id="notes">
                        <h3>Notes:</h3>
                        <xsl:for-each select="mona/body/div/p/note">
                            <p>
                                <sup><a>
                                    <xsl:attribute name="id">
                                        <xsl:value-of select="concat('note',./@n)"/>
                                    </xsl:attribute>
                                </a> Note <xsl:value-of select="./@n"/>
                                </sup>
                                <xsl:apply-templates/>
                                <br/>
                                <a>
                                    <xsl:attribute name="href">
                                        <xsl:value-of select="concat('#return', ./@n)"/>
                                    </xsl:attribute>
                                    return
                                </a>
                            </p>
                                <hr/>
                            
                        </xsl:for-each>
                    </div>

                </div>

            </body>

        </html>

    </xsl:template>
    <!-- title information -->

    <xsl:template match="header">
        <h1>
            <xsl:value-of select="title"/>
        </h1>
        <h2>
            <xsl:value-of select="author"/>
        </h2>
        <h3>
            <xsl:value-of select="date"/>
        </h3>
    </xsl:template>

    <!-- paragraphs -->
    <xsl:template match="p">
        <p>
            <xsl:apply-templates/>

        </p>

    </xsl:template>

    <!-- epigraph paragraph -->
    <xsl:template match="p[@type='epigraph']">
        <blockquote>
            <p>

                <xsl:apply-templates/>
            </p>
        </blockquote>

    </xsl:template>

    <!-- line break -->
    <xsl:template match="break">
        <br/>
        <xsl:apply-templates/>
    </xsl:template>

    <!-- section head -->
    <xsl:template match="head">
        <h4>
            <xsl:apply-templates/>
        </h4>
    </xsl:template>
    
    <!-- hi italics -->
    <xsl:template match="hi">
        <i><xsl:apply-templates/></i>
    </xsl:template>
    
    <!-- italics -->
    <xsl:template match="i">
        <i><xsl:apply-templates/></i>
    </xsl:template>

    <!-- images -->

    <xsl:template match="image">
        <div class="figure">
            <p>
                <img>
                    <xsl:attribute name="src">
                        <xsl:value-of select="./@file"/>
                    </xsl:attribute>
                    <xsl:attribute name="alt">
                        <xsl:value-of select="./@alt"/>
                    </xsl:attribute>
                    <xsl:attribute name="width">150</xsl:attribute>
                </img>
            </p>
            <p> Figure <xsl:number level="any"/>: <xsl:value-of select="./@alt"/>
            </p>
        </div>
    </xsl:template>

    <!-- links to notes -->
    <xsl:template match="notelink">
        <sup>
            <a>
                <xsl:attribute name="href">
                    <xsl:value-of select="concat('#note', ./@n)"/>
                </xsl:attribute>
                <xsl:attribute name="id">
                    <xsl:value-of select="concat('return', ./@n)"/>
                </xsl:attribute>
                <xsl:apply-templates/>
                <xsl:value-of select="./@n"/>
            </a>
        </sup>
    </xsl:template>
    
    
    <!-- notes -->
    <xsl:template match="note">
        <xsl:text> </xsl:text>
    </xsl:template>
    
</xsl:stylesheet>

