<xsl:stylesheet version="1.0" 
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html"/>

<!-- Main document format
     nav links are include from external file NAV.inc
-->

<xsl:template match="document">
    <html>
        <head>
		<link rel="icon" href="jhansi-flag.ico" type="image/x-icon" />
		<link rel="shortcut icon" href="jhansi-flag.ico" type="image/x-icon" />
        <meta name="Author" content="Allen Copsey"/>
        <meta name="Classification" content="Indian History"/>
        <meta name="Keywords" content="Lakshmibai, Rani of Jhansi, Lakshmi Bai, Jhansi Rani, Indian Mutiny, Indian Rebellion, First War of Independence"/>
        <xsl:if test="description">
            <meta name="Description" content="{./description}"/>
        </xsl:if>

        <xsl:apply-templates select='title'/>

        <!-- Only really needed if there are any dochref's -->

        <script language="javascript">
            function show(p)
            {
                x=window.open (p, 'docwin', 'width=600,height=420,scrollbars=yes,toolbar=yes,location=no,status=no,menubar=yes');
                x.focus();
            }
        </script>

        </head>
    <body>
	    <!--
    <script type="text/javascript" src="http://www.copsey-family.org/mystats/javascript/log.js"></script>
    <script>Count('http://www.copsey-family.org');</script>
    <noscript><p><img src="http://www.copsey-family.org/mystats/hit.php?groupe=GROUPE&amp;page=/~allenc/lakshmibai/{@base}.html" width="1" height="1" alt=""/></p></noscript> 
    -->
    <style>
	    a:link {color:blue}
	    a:visited {color:darkred}
    </style>
	    

        <!-- Document heading -->

        <font face="Arial,Helvetica">
        <table width="100%">
            <tr>
	        <td align="left" valign="top"><h1>Lakshmibai, Rani of Jhansi</h1></td>
                <td align="right" valign="top"><h1><xsl:value-of select="//title"/></h1>

                    <xsl:variable name="base" select="@base"/>

                    <xsl:variable name="ref" select="document('sitemap.xml')//pageref"/>
	            <xsl:for-each select="$ref">
	                <xsl:variable name="i" select="position()-1"/>
	                <xsl:variable name="j" select="position()+1"/>
	                <xsl:if test="@base=$base">
	                    <xsl:if test="$ref[$i]/@base">
	                        Previous: <a href="{$ref[$i]/@base}.html"><xsl:value-of select="$ref[$i]"/></a><br/>
		            </xsl:if>
	                    <xsl:if test="$ref[$j]/@base">
	                        Next: <a href="{$ref[$j]/@base}.html"><xsl:value-of select="$ref[$j]"/></a><br/>
		            </xsl:if>
	                </xsl:if>
	            </xsl:for-each>

		</td>
	    </tr>
        </table>
        </font>
    <!-- The document itself - a column table. The LH col being for the navigation-->
    <table>
        <tr><td align="left" valign="top">
        <xsl:variable name="nav" select="document('nav.html')/navlinks"/>
        <table border='1' height='100%' bgcolor="#cccccc" cellspacing='0' cellpadding='5'><tr><td align="left" valign="top">
            <xsl:copy-of select="$nav"/>

        </td></tr></table>

        </td><td align="left" valign="top">

        <!-- And now the main body of text, followed by any footnotes -->

        <font face="Arial,Helvetica" size="-1">
        <xsl:apply-templates select="body"/>
        <hr width="50%"/>

        <!-- If no note's then no Notes Section -->

        <xsl:if test="note">
            <h3>Notes</h3>
            <xsl:apply-templates select="note"/>
        </xsl:if>
        </font>
        </td></tr>
            <tr><td align='right' colspan='10'>
                    <xsl:variable name="base" select="@base"/>

                    <xsl:variable name="ref" select="document('sitemap.xml')//pageref"/>
	            <xsl:for-each select="$ref">
	                <xsl:variable name="i" select="position()-1"/>
	                <xsl:variable name="j" select="position()+1"/>
	                <xsl:if test="@base=$base">
	                    <xsl:if test="$ref[$i]/@base">
	                        Previous: <a href="{$ref[$i]/@base}.html"><xsl:value-of select="$ref[$i]"/></a><br/>
		            </xsl:if>
	                    <xsl:if test="$ref[$j]/@base">
	                        Next: <a href="{$ref[$j]/@base}.html"><xsl:value-of select="$ref[$j]"/></a><br/>
		            </xsl:if>
	                </xsl:if>
	            </xsl:for-each>
            </td></tr>
        <tr><td></td><td align="right" valign="top"><br/><br/>Last modified: __date__</td></tr>
    </table>
    </body>
    </html>
</xsl:template>


<xsl:template match="body">
    <xsl:apply-templates/>
</xsl:template>

<xsl:template match="p">
    <P>
    <xsl:apply-templates/>
    </P>
</xsl:template>

<xsl:template match="note">
        <p><font size="-1">
        <!-- Apply numbering only if there is more than one note -->
        <xsl:if test="//../note[2]">
        <xsl:number value="position()" format="i) "/>
        </xsl:if><xsl:value-of select="."/>
        </font></p>
</xsl:template>

<xsl:template match="title">
    <title>Lakshmibai, Rani of Jhansi - <xsl:value-of select="."/></title>
</xsl:template>

<xsl:template match="imagelink">
	<xsl:if test="@thumb">
		<a href="javascript:show('{@href}');">
			<img src="{@thumb}" align="left" valign="top"/>
		</a>
		<xsl:apply-templates/>
	</xsl:if>
	<xsl:if test="not(@thumb)">
    		<a href="javascript:show('{@href}');"><xsl:apply-templates/></a>
	</xsl:if>
</xsl:template>

<xsl:template match="h3">
    <xsl:copy-of select="."/>
</xsl:template>
<xsl:template match="h4">
    <xsl:copy-of select="."/>
</xsl:template>
<xsl:template match="img">
    <xsl:copy-of select="."/>
</xsl:template>
<xsl:template match="br">
    <xsl:copy-of select="."/>
</xsl:template>
<xsl:template match="blockquote">
    <blockquote>
    <xsl:apply-templates/>
    </blockquote>
</xsl:template>
<xsl:template match="i">
    <xsl:copy-of select="."/>
</xsl:template>
<xsl:template match="a">
    <xsl:copy-of select="."/>
</xsl:template>
<xsl:template match="ul">
    <ul>
    <xsl:apply-templates/>
    </ul>
</xsl:template>
<xsl:template match="b">
    <b><xsl:apply-templates/></b>
</xsl:template>
<xsl:template match="table">
	<table width="{@width}">
    		<xsl:apply-templates/>
	</table>
</xsl:template>
<xsl:template match="tr">
	<tr>
    		<xsl:apply-templates/>
	</tr>
</xsl:template>
<xsl:template match="td">
	<td align="{@align}" valign="{@valign}">
    		<xsl:apply-templates/>
	</td>
</xsl:template>
<xsl:template match="ul">
    <ul>
    <xsl:apply-templates/>
    </ul>
</xsl:template>
<xsl:template match="li">
    <li>
    <xsl:apply-templates/>
    </li>
</xsl:template>
<xsl:template match="dl">
    <dl>
    <xsl:apply-templates/>
    </dl>
</xsl:template>
<xsl:template match="dt">
    <dt>
    <xsl:apply-templates/>
    </dt>
</xsl:template>
<xsl:template match="dd">
    <dd>
    <xsl:apply-templates/>
    </dd>
</xsl:template>
<xsl:template match="caption">
    <caption>
    <xsl:apply-templates/>
    </caption>
</xsl:template>
<xsl:template match="font">
    <p>
    <xsl:copy-of select="."/>
    </p>
</xsl:template>

<!-- Links to remote sites as in a links page -->

<xsl:template match="remotesitelist">
    <dl>
    <xsl:apply-templates/>
    </dl>
</xsl:template>
<xsl:template match="remotesite">
    <dt>
    <xsl:for-each select="remoteref">
        <xsl:apply-templates select="."/>
        <xsl:if test='position() != 0'>
            <br/>
	</xsl:if>
    </xsl:for-each>
    </dt>
    <xsl:if test="./remotecomment">
    <dd>
    <xsl:apply-templates select="remotecomment"/>
    </dd>
    </xsl:if>
</xsl:template>
<xsl:template match="remoteref">
       <a href="{@url}" TARGET="linksite">
       <xsl:value-of select="."/>
       </a>
</xsl:template>

<!-- List of questions and answers -->

<xsl:template match="qandalist">
    <xsl:for-each select="qanda/question">
        <a href="#{generate-id(.)}"><xsl:value-of select="."/></a><BR/>
    </xsl:for-each>
    <xsl:apply-templates/>
</xsl:template>
<xsl:template match="qanda">
       <h3><a name="{generate-id(question)}"></a><xsl:value-of select="question"/></h3>
       <xsl:apply-templates select="answer"/>
</xsl:template>

<!-- Quotes with autor an comment -->

<xsl:template match="quote">
    "<xsl:apply-templates select="quotetext"/>"
    <ul>
    -- <xsl:apply-templates select="quoteauthor"/><br/>
    <i><xsl:apply-templates select="quotecomment"/></i>
    </ul>
</xsl:template>


<!-- List of events with date and comment -->

<xsl:template match="eventlist">
    <table>
    <xsl:apply-templates/>
    </table>
</xsl:template>

<xsl:template match="event">
    <tr ALIGN="LEFT" VALIGN="TOP">
    <td width="100">
    <xsl:apply-templates select="eventdate"/>
    </td>
    <td>
    <xsl:apply-templates select="eventtitle"/><br/>
    <xsl:apply-templates select="eventcomment"/>
    <xsl:if test='moredetails'>
	    <xsl:text> </xsl:text>(<a href='{moredetails/@href}'>more...</a>)
    </xsl:if>
    </td>
    </tr>
</xsl:template>

<xsl:template match="eventtitle">

    <b>
    <xsl:apply-templates/>
    </b>
</xsl:template>

<xsl:template match="eventcomment">

    <i>
    <xsl:apply-templates/>
    </i>
</xsl:template>

<!-- List of books with title, author, publishing details and comment -->

<xsl:template match="booklist">
    <dl>
    <xsl:apply-templates>
        <xsl:sort select="bookauthor"/>
    </xsl:apply-templates>
    </dl>
</xsl:template>
<xsl:template match="book">
    <dt>
    <b>
    <xsl:apply-templates select="bookauthor"/> - 
    <xsl:apply-templates select="booktitle"/>
    </b>
    (<xsl:apply-templates select="bookpublisher"/>)
    </dt><dd>
    <xsl:apply-templates select="bookcomment"/>
    </dd>
</xsl:template>
<xsl:template match="booktitle">
    <xsl:value-of select="."/>
</xsl:template>
<xsl:template match="bookauthor">
    <xsl:value-of select="."/>
</xsl:template>
<xsl:template match="bookpublisher">
    <xsl:value-of select="."/>
</xsl:template>
<xsl:template match="bookcomment">
    <xsl:value-of select="."/>
</xsl:template>

<!-- List of document refs. Documents are displayed in a
     fresh window generated by the javascript in the head -->

<xsl:template match="docreflist">
    <table>
    <xsl:apply-templates/>
    </table>
</xsl:template>
<xsl:template match="docref">
    <tr align="left" valign="top">
    <td>
    <xsl:apply-templates select="dochref"/> 
    </td><td> 
    <xsl:apply-templates select="docauthor"/>
    </td><td>
    <xsl:apply-templates select="docaddress"/>
    </td><td>
    <xsl:apply-templates select="doccomment"/>
    </td>
    </tr>
</xsl:template>
<xsl:template match="dochref">

    <!-- Kludge to allow for url attribute or url value -->
    <!-- The not so lazy would redo it all -->

    <xsl:if test="@url">
       <a href="javascript:show('{@url}')">
	       <xsl:apply-templates />
       </a>
    </xsl:if>
    <xsl:if test="not (@url)">
       <a href="javascript:show('{.}')">
       <xsl:value-of select="../docdate"/>
       </a>
    </xsl:if>
</xsl:template>


<xsl:template match="mapsection">
    <xsl:apply-templates/>
</xsl:template>
<xsl:template match="mapsubsection">
    <xsl:apply-templates/>
</xsl:template>
<xsl:template match="pageref">
    <xsl:variable name="ref" select="document(concat (string(@base), '.xml'))/document"/>
    <dt><a href="{@base}.html">
        <xsl:choose>
        <xsl:when test="not (.='')">
            <xsl:value-of select="."/>
        </xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="$ref/title"/>
        </xsl:otherwise>
        </xsl:choose>
    </a></dt>
    <dd><xsl:value-of select="$ref/description"/></dd>
</xsl:template>
<xsl:template match="mapsectiontitle">
    <h4><xsl:apply-templates/></h4>
</xsl:template>

<xsl:template match="documentsref">
    <xsl:variable name="ref" select="document(concat (string(@base), '.xml'))/document"/>
    <xsl:text>See </xsl:text>
    <a href="{concat (string(@base), '.html')}">
        <xsl:value-of select="$ref/title"/>
    </a>
    <xsl:text>: </xsl:text>
    <xsl:value-of select="$ref/description"/>
    <dl>
        <xsl:for-each select="$ref/body/docreflist/docref">
        <xsl:sort select="docauthor"/>
        <xsl:sort select="docnumdate"/>
            <dt><xsl:value-of select="docauthor"/><xsl:text>:  </xsl:text><xsl:value-of select="docdate"/></dt>
            <dd><xsl:value-of select="doccomment"/></dd>
        </xsl:for-each>
    </dl>
</xsl:template>
</xsl:stylesheet>


