<?xml version="1.0"?>
	<!DOCTYPE CTMLentities SYSTEM "ctml_entities.dtd">
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">




<!--
CTML 4.1
reduced XSLT stylesheet for Bibliographical Resource Markup Language (BRML)
2004 may 6
(C)2004 by Gian Pietro Basello & Stefano Buscherini
gpbasello@virgilio.it
elam@elamit.net
www.elamit.net
-->



<!-- direttive XSL -->

<xsl:output method="html"
              version="4.0"
              doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN"
              doctype-system="http://www.w3.org/TR/REC-html40/loose.dtd"
              encoding="ISO-8859-1"/>

<xsl:strip-space elements="*"/>

<xsl:key name="morphkey" match="log[count(child::*)= '0']/@stem" use="."/>
<xsl:key name="skey" match="s/@value" use="."/>
<xsl:key name="skey_labat" match="s/@labat" use="."/>

<!-- **** **** **** **** -->



<xsl:template match="/">

<!-- intestazione del file HTML -->

<html>
<head>
<meta name="keywords" content="Elam,Elamites,elamiti,elamico"/>
<meta name="description" content="Storia, lingua e cultura dell'antico Elam"/>
<meta name="author" content="Basello Gian Pietro, Buscherini Stefano"/>
<link rel="stylesheet" type="text/css" href="ctml.css"/>
<title><xsl:value-of select="name"/></title>


<!-- codice javascript client side -->

<!-- codice per le evidenziazioni
Andrà rivisto sia il codice sia il sistema di id sotteso (creato dal foglio XSL più avanti) in modo che su qualsiasi elemento si vada con il mouse, vengano subito evidenziati tutti gli elementi correlati negli altri layers -->

<script language="javascript">
<![CDATA[


function toggle()
{
    c=0;
    ob = document.getElementsByTagName("span");

    while (ob[c] != undefined) {
    		if (document.settings.display_notes.checked) ob[c].style.display = "inline";
    		else ob[c].style.display = "none"
           c++; }
}





function put_index (value, index)
{
// da fare, ho solo copitao le regular expression di tuppime

str = str.replace(/([aeiouAEIOU])([^AEIOUaeiou\d\s\.\-]*)2([^\d])/g, "&$1acute;$2$3");
        str = str.replace(/([aeiouAEIOU])([^AEIOUaeiou\d\s\.\-]*)3([^\d])/g, "&$1grave;$2$3");
        str = str.replace(/([a-zA-Z])([^\s\-\.\d]*)([\d]+)/g, "$1$2<sub>$3</sub>");
}

function element_on (sign_start, sign_end, word_start)
{
    c=0;
    
    ob = document.getElementsByTagName("a");
        
    while (ob[c] != undefined) {
        if (ob[c].idlog == word_start)  ob[c].style.background = "yellow";
        if (ob[c].sid >= sign_start && ob[c].sid <= sign_end) ob[c].style.background = "yellow";
        c++; }
}

function element_off (sign_start, sign_end, word_start)
{
    c=0;

    ob = document.getElementsByTagName("a");
    
    while (ob[c] != undefined) {
        if (ob[c].idlog == word_start)  ob[c].style.background = "";
        if (ob[c].sid >= sign_start && ob[c].sid <= sign_end) ob[c].style.background = "";
        c++;
    } 
}



// nuove funzioni

function s_on (s_id, log_id)
{
    c=0;
    
    ob = document.getElementsByTagName("a");
        
    while (ob[c] != undefined) {
		if (ob[c].sid != undefined ) { if (ob[c].sid == s_id) ob[c].style.background = "yellow"; }
		else if (ob[c].idlog == log_id)  ob[c].style.background = "yellow";
		
        c++; }
}

function s_off (s_id, log_id)
{
    c=0;
    
    ob = document.getElementsByTagName("a");
        
    while (ob[c] != undefined) {
		if (ob[c].sid != undefined ) { if (ob[c].sid == s_id) ob[c].style.background = ""; }
		else if (ob[c].idlog == log_id)  ob[c].style.background = "";
		
        c++; }
}

function log_on (log_id)
{
    c=0;
    
    ob = document.getElementsByTagName("a");
        
    while (ob[c] != undefined) {
        if (ob[c].idlog == log_id)  ob[c].style.background = "yellow";
        c++; }
}

function log_off (log_id)
{
    c=0;

    ob = document.getElementsByTagName("a");
    
    while (ob[c] != undefined) {
        if (ob[c].idlog == log_id)  ob[c].style.background = "";
        c++;
    } 
}




function collapse (clid)
{
    c=0;
    
    while (document.all[c] != undefined) {
        if (document.all[c].idlog == clid)  {
            if (document.all[c].style.display == "block")  document.all[c].style.display = "none";
            else document.all[c].style.display = "block";
        }
        if (document.all[c].clid_start == clid && document.all[c].clid_end == clid)  {
            if (document.all[c].style.display == "block")  document.all[c].style.display = "none";
            else  document.all[c].style.display = "block";
        }

        c++;
    }
}


]]>
</script>

<!-- codice per il riordinamento -->
<SCRIPT for="window" event="onload">
        <xsl:comment>
            <![CDATA[
                stylesheet = document.XSLDocument;
                source = document.XMLDocument;
                sortField = document.XSLDocument.selectSingleNode("//xsl:sort[../../../@match='bibliography']/@select");
			sortFieldGlossary = document.XSLDocument.selectSingleNode("//xsl:sort[../../../../../@match = 'glossary']/@select");
                sortFieldPal = document.XSLDocument.selectSingleNode("//xsl:sort[../../../../../@match='palaeography']/@select");
                typeFieldPal = document.XSLDocument.selectSingleNode("//xsl:sort[../../../../../@match='palaeography']/@data-type");

                // alert(sortFieldGlossary.value);
            ]]>
        </xsl:comment>
</SCRIPT>
    
<SCRIPT>
        <xsl:comment>
            <![CDATA[
                function sort(field)
                    {
                    sortField.value = field;
                    // ad ogni riordinamento si crea un sotto body_ref per motivi vari allora richiama sempre il primo
                    document.all("body_ref",0).innerHTML = source.documentElement.getElementsByTagName("bibliography")[0].transformNode(stylesheet);
                    }
                    
                function sortGlossary(field)
                    {
                    sortFieldGlossary.value = field;
                    document.all("body_glossary",0).innerHTML = source.documentElement.getElementsByTagName("glossary")[0].transformNode(stylesheet);
                    }
                function sortPal(field, dt)
                    {
                    sortFieldPal.value = field;
                    typeFieldPal.value = dt;
                    document.all("body_pal",0).innerHTML = source.documentElement.getElementsByTagName("palaeography")[0].transformNode(stylesheet);
                    }

            ]]>
        </xsl:comment>
</SCRIPT>
</head>

<body>
<h1><xsl:value-of select="name"/></h1>

<!--

<xsl:apply-templates select="//log[ancestor-or-self::log/@lang='persian-old' ]" mode="interlinear"/>
<xsl:apply-templates select="//div[ancestor-or-self::div/@script = 'persian-old' " mode="img"/>
-->


<!-- elaborazione del flusso -->
<xsl:apply-templates/>


<!-- chiusura pagina -->
<hr/>

<p class="did">
©2004 Copyright by <a href="http://digilander.iol.it/elam/autore.htm" target="_blank">Gian Pietro <b>Basello</b></a> &lt;<a href="mailto:elam@elamit.net">elam@elamit.net</a>&gt; and Stefano <b>Buscherini</b><br/>
Napoli, 6/V/2004<br/><!--
<script language="JavaScript">
    document.write("<b>" + location.href + "</b><br/>");
    document.write("Encoding: <b>" + document.charset + "</b> Last modified: <b>" + document.lastModified + "</b>");
//</script>-->
</p>

</body>
</html>

</xsl:template>



<xsl:template match="ctml">

    <xsl:apply-templates/>
<!--
<h3>Text</h3>

<xsl:apply-templates select="cli"/>

<table border="0" margin="0">
<xsl:apply-templates select="div"/>
</table>

<br/>

<xsl:apply-templates select="cl"/>
-->
</xsl:template>





<!-- BIBLIOGRAPHY -->

<xsl:template match="bibliography">
    <div id="body_ref">
        <xsl:attribute name="sid"><!-- perché SID???? è lo stesso dei segni!!! -->
            <xsl:value-of select="concat(name(.),position())"/>
        </xsl:attribute>
    <h1>
    <xsl:choose>
        <xsl:when test="@title = false() ">
            Bibliography
        </xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="@title"/>
        </xsl:otherwise>
    </xsl:choose>
    </h1>

    <p><form name="settings">Sort by: <a href="javascript:void sort('author')">author</a>&#xa0;<a href="javascript:void sort('year')">year</a>&#xa0;<a href="javascript:void sort('title')">title</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="display_notes" onclick="toggle()" checked=""/> Display personal notes</form></p>

        <xsl:apply-templates>
            <xsl:sort select="author"/>
            <xsl:sort select="year"/>
            <xsl:sort select="author"/>
        </xsl:apply-templates>
    </div>

</xsl:template>





<xsl:template match="ref">
	<a>
		<xsl:choose>
        		<xsl:when test="@id = true()">
		            <xsl:attribute name="idref"><xsl:value-of select="@id"/></xsl:attribute>
        		</xsl:when>
	    </xsl:choose>
     
    		<xsl:choose>
		     <xsl:when test="name(..) = 'bibliography' ">
				<p style="text-indent: -7mm; margin-left: 7mm">
		           	<xsl:choose>
						<xsl:when test="@status='unread'"><span class="marker">*</span></xsl:when>
					</xsl:choose>
				<xsl:apply-templates/>.</p>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates/>
			</xsl:otherwise>
		</xsl:choose>
	</a>
</xsl:template>


<xsl:template match="author">
    <a>
    <xsl:attribute name="title">
        <xsl:for-each select="./@*">
            <xsl:value-of select="name()"/>&#160;<xsl:value-of select="."/>&#160;
        </xsl:for-each>
    </xsl:attribute>
    <xsl:choose>
        <xsl:when test="position() = 1 and name(../..) = 'bibliography' ">
            <b><xsl:value-of select="last"/></b>, <xsl:value-of select="first"/>
        </xsl:when>
        <xsl:otherwise>
                        <xsl:value-of select="first"/>&#xa0;<b><xsl:value-of select="last"/></b>
        </xsl:otherwise>
    </xsl:choose>
    </a>

    <xsl:choose>
        <xsl:when test="@type != '' ">,&#xa0;<xsl:value-of select="@type"/></xsl:when>
    </xsl:choose>
    <xsl:choose>
        <xsl:when test="position () =count(../author)-1"> &amp; </xsl:when>
        <xsl:when test="position () != count(../author)">, </xsl:when>
        <xsl:when test="position () = count(../author) and (name(../..) != 'bibliography' and name(..) != 'festschrift')">, </xsl:when>
    </xsl:choose>

</xsl:template>


<xsl:template match="year">
    <xsl:choose>
        <xsl:when test = "name(../..) != 'in' ">
            (<xsl:apply-templates/>)
        </xsl:when>
        <xsl:otherwise>,&#xa0;</xsl:otherwise>
    
    </xsl:choose>
</xsl:template>


<xsl:template match="title">
    <xsl:choose>
        <xsl:when test="name(../..) = 'serie' ">
        	<xsl:value-of select="."/>
        </xsl:when>
        <xsl:when test="count(../in) = 0">
            <i><xsl:value-of select="."/></i>
        </xsl:when>
        <xsl:otherwise>
            &#x2018;<xsl:value-of select="."/>&#x2019;,
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>


<xsl:template match="festschrift">(Festschrift <xsl:apply-templates/>)</xsl:template>

<xsl:template match="in">
    in
    <xsl:apply-templates/>
</xsl:template>


<xsl:template match="serie"> (<xsl:apply-templates/>)</xsl:template>


<xsl:template match="inner">,&#xa0;<xsl:value-of select="@type"/>
	<xsl:choose>
		<xsl:when test="@from = @to">&#xa0;<xsl:value-of select="@from"/>
		</xsl:when>
		<xsl:otherwise>s&#xa0;<xsl:value-of select="@from"/>-<xsl:value-of select="@to"/>
		</xsl:otherwise>
	</xsl:choose>
    <xsl:apply-templates/>
</xsl:template>


<xsl:template match="from">
    <xsl:value-of select="."/>-
</xsl:template>


<xsl:template match="place">, <xsl:value-of select="."/></xsl:template>

<xsl:template match="publisher">: <xsl:value-of select="."/></xsl:template>

<xsl:template match="notes"> <span class="mark">&#xa0;[<xsl:apply-templates/>]</span></xsl:template>

<!--
<xsl:template match="abbr"><span class="abbr"><xsl:value-of select="."/></span></xsl:template>
-->

<!-- ************************ -->





<!-- elaborazione degli elementi HTML -->
<xsl:template match="hr | h1 | h2 | h3 | h4 | h5 | h6 | p | b | u | i | em | ul | ol | li | table | tr | td | sub | sup">
    <xsl:element name="{name(.)}">
        <xsl:for-each select="@*">
            <xsl:attribute name="{name(.)}"><xsl:value-of select="."/></xsl:attribute>
        </xsl:for-each>
        
        <xsl:apply-templates/>
    </xsl:element>
</xsl:template>


<!-- compatibilità con il convertor, 12/02/2003 -->
<xsl:template match="text | line | words">
	<xsl:apply-templates/>
</xsl:template>

</xsl:stylesheet>

