<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcq="http://purl.org/dc/qualifiers/1.0/" xmlns:math="http://exslt.org/math" xmlns:set="http://exslt.org/sets" xmlns:date="http://exslt.org/dates-and-times" xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl date math set" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:import href="/www/ximsroot/skins/default/stylesheets/referencelibrary_cv_defaultstyle.xsl"/>
<xsl:import href="http://www.uibk.ac.at/stylesheets/include/07/common.xsl"/>
<xsl:import href="nanobio.xsl"/>

<xsl:output method="xml" encoding="iso-8859-1" media-type="text/html" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" indent="no"/>

<xsl:key name="year" match="/document/context/object/children/object" use="substring(reference_values/reference_value[property_id=3]/value,1, 4)"/>

<!--<xsl:key name="reftype_id_by_date" match="children/object" use="concat(reference_type_id, '+', reference_values/reference_value[property_id=3]/value)" />-->

<xsl:param name="css" select="/www/ximsroot/skins/default/stylesheets/reference_library_cv_defaultstyle.css"/>
<xsl:param name="ptitle"/>
<xsl:param name="style"/>
<xsl:param name="author_lname"/>

<xsl:variable name="volumerefpropid" select="/document/reference_properties/reference_property[name='volume']/@id"/>
<xsl:variable name="issuerefpropid" select="/document/reference_properties/reference_property[name='issue']/@id"/>
<xsl:variable name="tpagesrefpropid" select="/document/reference_properties/reference_property[name='tpages']/@id"/>
<xsl:variable name="spagerefpropid" select="/document/reference_properties/reference_property[name='spage']/@id"/>
<xsl:variable name="epagerefpropid" select="/document/reference_properties/reference_property[name='epage']/@id"/>
<xsl:variable name="identifierrefpropid" select="/document/reference_properties/reference_property[name='identifier']/@id"/>
<xsl:variable name="urlrefpropid" select="/document/reference_properties/reference_property[name='url']/@id"/>
<xsl:variable name="url2refpropid" select="/document/reference_properties/reference_property[name='url2']/@id"/>
<xsl:variable name="artnumrefpropid" select="/document/reference_properties/reference_property[name='artnum']/@id"/>
<xsl:variable name="conftitlerefpropid" select="/document/reference_properties/reference_property[name='conf_title']/@id"/>
<xsl:variable name="confdaterefpropid" select="/document/reference_properties/reference_property[name='conf_date']/@id"/>
<xsl:variable name="confvenuerefpropid" select="/document/reference_properties/reference_property[name='conf_venue']/@id"/>
<xsl:variable name="confurlrefpropid" select="/document/reference_properties/reference_property[name='conf_url']/@id"/>
<xsl:variable name="reprintrefpropid" select="/document/reference_properties/reference_property[name='preprint_identifier']/@id"/>
<xsl:variable name="placepropid" select="/document/reference_properties/reference_property[name='place']/@id"/>
<xsl:variable name="publisherpropid" select="/document/reference_properties/reference_property[name='pub']/@id"/>
<xsl:variable name="isbnpropid" select="/document/reference_properties/reference_property[name='isbn']/@id"/>

<xsl:template match="/document/context/object">
    <html>
        <head>
            <xsl:call-template name="meta"/>

            <!-- Head fehlt noch -->

            <link type="text/css" rel="stylesheet" href="http://www.uibk.ac.at/stylesheets/default.css"/>

            <link rel="stylesheet" href="/www/ximsroot/skins/default/stylesheets/reference_library.css" type="text/css"/>

        <title>

            <xsl:value-of select="title"/> - Institut für Ionenphysik und Angewandte Physik - Universität Innsbruck

        </title>
        </head>
        <body>
            <table width="100%">
                <xsl:call-template name="iap_header_xims">
                    <xsl:with-param name="location" select="location" />
                    <xsl:with-param name="style" select="$style" />
                </xsl:call-template>
                <tr><td>
                    <xsl:if test="$ptitle != ''">
                        <h1 id="reflib_ptitle"><span class="reflib_ptitle"><xsl:value-of select="$ptitle"/></span></h1>
                    </xsl:if>
                    Download <a target="_new" href="?style=word_xmlimport;author_lname={$author_lname};ptitle={$ptitle}">WordML</a> to open with MS Word.
                </td></tr>
            </table>
            <xsl:choose>
                <xsl:when test="contains($request.uri,'/nanobiopubl2010')">
                    2011-2010, <a href="http://xims.uibk.ac.at/gopublic/content/uniweb/ionen-angewandte-physik/nanobio/publ/nanobiopubl2005?style={$style};author_lname={$author_lname};ptitle={$ptitle}">2009-2005</a>, <a href="http://xims.uibk.ac.at/gopublic/content/uniweb/ionen-angewandte-physik/nanobio/publ/nanobiopubl2000?style={$style};author_lname={$author_lname};ptitle={$ptitle}">2004-2000</a>,
<a href="http://xims.uibk.ac.at/gopublic/content/uniweb/ionen-angewandte-physik/nanobio/publ/nanobiopubl1995?style={$style};author_lname={$author_lname};ptitle={$ptitle}">1999-1995</a>
                </xsl:when>
                <xsl:when test="contains($request.uri,'/nanobiopubl2005')">
                    <a href="http://xims.uibk.ac.at/gopublic/content/uniweb/ionen-angewandte-physik/nanobio/publ/nanobiopubl2010?style={$style};author_lname={$author_lname};ptitle={$ptitle}">2011-2010</a>, 2009-2005, <a href="http://xims.uibk.ac.at/gopublic/content/uniweb/ionen-angewandte-physik/nanobio/publ/nanobiopubl2000?style={$style};author_lname={$author_lname};ptitle={$ptitle}">2004-2000</a>,
<a href="http://xims.uibk.ac.at/gopublic/content/uniweb/ionen-angewandte-physik/nanobio/publ/nanobiopubl1995?style={$style};author_lname={$author_lname};ptitle={$ptitle}">1999-1995</a>
                </xsl:when>
                <xsl:when test="contains($request.uri,'/nanobiopubl2000')">
                    <a href="http://xims.uibk.ac.at/gopublic/content/uniweb/ionen-angewandte-physik/nanobio/publ/nanobiopubl2010?style={$style};author_lname={$author_lname};ptitle={$ptitle}">2011-2010</a>, <a href="http://xims.uibk.ac.at/gopublic/content/uniweb/ionen-angewandte-physik/nanobio/publ/nanobiopubl2005?style={$style};author_lname={$author_lname};ptitle={$ptitle}">2009-2005</a>, 2004-2000, <a href="http://xims.uibk.ac.at/gopublic/content/uniweb/ionen-angewandte-physik/nanobio/publ/nanobiopubl1995?style={$style};author_lname={$author_lname};ptitle={$ptitle}">1999-1995</a>
                </xsl:when>
                <xsl:otherwise>
                    <a href="http://xims.uibk.ac.at/gopublic/content/uniweb/ionen-angewandte-physik/nanobio/publ/nanobiopubl2010?style={$style};author_lname={$author_lname};ptitle={$ptitle}">2010</a>, <a href="http://xims.uibk.ac.at/gopublic/content/uniweb/ionen-angewandte-physik/nanobio/publ/nanobiopubl2005?style={$style};author_lname={$author_lname};ptitle={$ptitle}">2009-2005</a>, <a href="http://xims.uibk.ac.at/gopublic/content/uniweb/ionen-angewandte-physik/nanobio/publ/nanobiopubl2000?style={$style};author_lname={$author_lname};ptitle={$ptitle}">2004-2000</a>,
1999-1995
                </xsl:otherwise>
            </xsl:choose>
            <div id="reflib_citebody">
                <xsl:for-each select="children/object[substring(reference_values/reference_value[property_id=3]/value,1, 4) != '' and count(. | key('year', substring(reference_values/reference_value[property_id=3]/value,1, 4))[1]) = 1]">
                    <!--<xsl:sort select="substring(., 1,4)" order="descending"/>-->
                    <xsl:sort select="substring(reference_values/reference_value[property_id=3]/value,1, 4)" order="descending"/>
                    <xsl:variable name="date" select="substring(reference_values/reference_value[property_id=3]/value,1, 4)"/>
                    <h2>
                        <span class="reflib_year"><xsl:value-of select="$date"/></span>
                        <!--(<xsl:value-of select="count(/document/context/object/children/object[reference_values/reference_value[property_id=3 and starts-with(value,$date)]]/reference_type_id)"/>)-->
                    </h2>
                    <div class="reflib_citedivyear">
                        <xsl:for-each select="/document/context/object/children/object
                                      [generate-id(reference_type_id)=generate-id(key('reftype_id',reference_type_id)[1])]/reference_type_id">
                            <!-- and reference_values/reference_value[property_id=3]/value=$date -->
                            <xsl:sort select="/document/reference_types/reference_type[@id=current()]/name" order="ascending"/>
                            <xsl:variable name="reference_type_id" select="."/>
                            <xsl:call-template name="object_per_reftype">
                                <xsl:with-param name="date" select="$date"/>
                                <xsl:with-param name="reference_type_id" select="$reference_type_id"/>
                            </xsl:call-template>
                        </xsl:for-each>
                    </div>
                </xsl:for-each>

                <!-- Deal with entries without a year -->

                <xsl:if test="children/object[string-length(reference_values/reference_value[property_id=3]/value)=0]">
                    <h2><span class="reflib_year">Without Year</span></h2>
                    <div class="reflib_citedivyear">
                        <xsl:if test="/document/context/object/children/object[reference_values/reference_value[property_id=3 and string-length(value)=0] and reference_type_id = $preprint_id]">
                            <h3>
                                <xsl:value-of select="/document/reference_types/reference_type[@id=$preprint_id]/name"/>s
                            </h3>
                            <ul class="reflib_citelist">
                                <xsl:for-each select="/document/context/object/children/object[reference_values/reference_value[property_id=3 and string-length(value)=0] and reference_type_id = $preprint_id]">
                                    <xsl:sort select="title" order="ascending"/>
                                    <xsl:apply-templates select="." mode="divlist"/>
                                </xsl:for-each>
                            </ul>
                        </xsl:if>
                        <xsl:for-each select="/document/context/object/children/object
                            [string-length(reference_values/reference_value[property_id=3]/value)=0 and generate-id(reference_type_id)=generate-id(key('reftype_id',reference_type_id)[1])]/reference_type_id">
                            <xsl:sort select="/document/reference_types/reference_type[@id=current()]/name" order="ascending"/>
                            <xsl:variable name="reference_type_id" select="."/>
                            <h3>
                                <span class="reflib_referencetype"><xsl:value-of select="/document/reference_types/reference_type[@id=$reference_type_id]/name"/>s</span>
                            </h3>
                            <ul class="reflib_citelist">
                                <xsl:for-each select="/document/context/object/children/object[reference_values/reference_value[property_id=3 and string-length(value)=0] and reference_type_id = $reference_type_id]">
                                    <xsl:sort select="title" order="ascending"/>
                                    <xsl:apply-templates select="." mode="divlist"/>
                                </xsl:for-each>
                            </ul>
                        </xsl:for-each>
                    </div>
                </xsl:if>
            </div>
        </body>
    </html>
</xsl:template>

<xsl:template name="object_per_reftype">
    <xsl:param name="date"/>
    <xsl:param name="reference_type_id"/>    
    <!-- Hmm, there must be a better way instead of doing that xsl:if here... -->
    <xsl:if test="/document/context/object/children/object[reference_values/reference_value[property_id=3 and starts-with(value,$date)] and reference_type_id = $reference_type_id]">
        <h3>
            <span class="reflib_referencetype"><xsl:value-of select="/document/reference_types/reference_type[@id=$reference_type_id]/name"/>s</span>
        </h3>
        <ol class="reflib_citelist">
            <xsl:for-each select="/document/context/object/children/object[reference_values/reference_value[property_id=3 and starts-with(value,$date)] and reference_type_id = $reference_type_id]">
<!--                <xsl:sort select="substring(reference_values/reference_value[property_id=3]/value,1,4)" order="descending"/>-->
                <xsl:sort select="title" order="ascending"/>
                <xsl:apply-templates select="." mode="divlist"/>
            </xsl:for-each>
        </ol>
    </xsl:if>
</xsl:template>    

<xsl:template match="children/object" mode="divlist">
    <xsl:variable name="referencenumber"><xsl:number count="object" /></xsl:variable>
    <xsl:variable name="date" select="reference_values/reference_value[property_id=$daterefpropid]/value"/>
    <xsl:variable name="btitle" select="reference_values/reference_value[property_id=$btitlerefpropid]/value"/>
    <xsl:variable name="volume" select="reference_values/reference_value[property_id=$volumerefpropid]/value"/>
    <xsl:variable name="issue" select="reference_values/reference_value[property_id=$issuerefpropid]/value"/>
    <xsl:variable name="verlag" select="reference_values/reference_value[property_id=$publisherpropid]/value"/>
    <xsl:variable name="ort" select="reference_values/reference_value[property_id=$placepropid]/value"/>
    <xsl:variable name="tpages" select="reference_values/reference_value[property_id=$tpagesrefpropid]/value"/>
    <xsl:variable name="spage" select="reference_values/reference_value[property_id=$spagerefpropid]/value"/>
    <xsl:variable name="epage" select="reference_values/reference_value[property_id=$epagerefpropid]/value"/>
    <xsl:variable name="identifier" select="reference_values/reference_value[property_id=$identifierrefpropid]/value"/>
    <xsl:variable name="url" select="reference_values/reference_value[property_id=$urlrefpropid]/value"/>
    <xsl:variable name="url2" select="reference_values/reference_value[property_id=$url2refpropid]/value"/>
    <xsl:variable name="artnum" select="reference_values/reference_value[property_id=$artnumrefpropid]/value"/>
    <xsl:variable name="conf_title" select="reference_values/reference_value[property_id=$conftitlerefpropid]/value"/>
    <xsl:variable name="conf_date" select="reference_values/reference_value[property_id=$confdaterefpropid]/value"/>
    <xsl:variable name="conf_venue" select="reference_values/reference_value[property_id=$confvenuerefpropid]/value"/>
    <xsl:variable name="conf_url" select="reference_values/reference_value[property_id=$confurlrefpropid]/value"/>
    <xsl:variable name="reprint" select="reference_values/reference_value[property_id=$reprintrefpropid]/value"/>
    <xsl:variable name="isbn" select="reference_values/reference_value[property_id=$isbnpropid]/value"/>
    <xsl:variable name="serial_id" select="serial_id"/>

    <li class="reflib_citation" name="reflib_citation">
        <span class="reflib_citation">
            <span class="reflib_authors">
                <xsl:choose>
                    <xsl:when test="authorgroup/author">
                        <xsl:apply-templates select="authorgroup/author">
                            <xsl:sort select="./position" order="ascending" data-type="number"/>
                        </xsl:apply-templates>
                    </xsl:when>
                    <xsl:when test="editorgroup/author">
                        <xsl:apply-templates select="editorgroup/author">
                            <xsl:sort select="./position" order="ascending" data-type="number"/>
                        </xsl:apply-templates> (Ed<xsl:if test="count(editorgroup/author) &gt; 1">s</xsl:if>.)
                    </xsl:when>
                    <xsl:otherwise>
                        Anonymous</xsl:otherwise>
                </xsl:choose>
            </span>,
            <span class="reflib_title">
                <xsl:value-of select="reference_values/reference_value[property_id=$titlerefpropid]/value"/>.
            </span>
<!--            <xsl:if test="$conf_title != ''">,
                <span class="reflib_conference_title">
                    <xsl:choose>
                        <xsl:when test="$conf_url != ''">
                            <a href="{$conf_url}">
                                <xsl:value-of select="$conf_title"/>
                            </a>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="$conf_title"/>
                        </xsl:otherwise>
                    </xsl:choose>
                </span>
                <xsl:if test="$conf_venue != ''">
                    <xsl:text> (</xsl:text>
                    <span class="reflib_conference_venue">
                        <xsl:value-of select="$conf_venue"/>
                    </span>
                    <xsl:if test="$conf_date != ''">,
                        <span class="reflib_conference_date">
                            <xsl:value-of select="$conf_date"/>
                        </span>
                    </xsl:if>
                    <xsl:text>)</xsl:text>
                </xsl:if>
            </xsl:if>
-->
            <xsl:if test="$serial_id != '' or $btitle != ''">
                <em><span class="reflib_serial">
                    <xsl:choose>
                        <xsl:when test="$serial_id != ''">
                            <xsl:value-of select="/document/context/vlserials/serial[id=$serial_id]/title"/>
                        </xsl:when>
                        <xsl:otherwise>
                            in: <xsl:value-of select="$btitle"/>
                        </xsl:otherwise>
                    </xsl:choose>
                </span></em><xsl:text> </xsl:text>
            </xsl:if>
            <xsl:if test="$issue != ''"><span class="reflib_issue"><xsl:value-of select="$issue"/>/</span></xsl:if>
            <xsl:if test="$volume != ''"><span class="reflib_volume"><strong><xsl:value-of select="$volume"/></strong></span></xsl:if>
            <xsl:if test="editorgroup/author"><xsl:if test="count(authorgroup/author) != 0">
                <xsl:text> (</xsl:text>
                <span class="reflib_editors">Ed<xsl:if test="count(editorgroup/author) &gt; 1">s</xsl:if>.:
                    <xsl:apply-templates select="editorgroup"/>
                </span>
                <xsl:text>)</xsl:text>
            </xsl:if></xsl:if>
            <xsl:if test="$verlag != ''">
                <span class="reflib_volume"><xsl:text> </xsl:text><xsl:value-of select="$verlag"/></span>
            </xsl:if>
            <xsl:if test="$ort != ''">
                <span class="reflib_volume">, <xsl:value-of select="$ort"/></span>
            </xsl:if>
            <xsl:if test="$isbn != ''">
                <span class="reflib_volume">, ISBN: <xsl:value-of select="$isbn"/></span>
            </xsl:if>
            <xsl:if test="$date != ''">&#xa0;<span class="reflib_date">(<xsl:value-of select="substring($date,1,4)"/>)</span></xsl:if>
            <xsl:choose>
                <xsl:when test="$spage != ''">
                    <span class="reflib_page">&#160;<xsl:value-of select="$spage"/> <xsl:if test="$epage != ''">-<xsl:value-of select="$epage"/></xsl:if></span>
                </xsl:when>
                <xsl:when test="$tpages != ''">
                    <span class="reflib_page">&#160;<xsl:value-of select="$tpages"/> p.</span>
                </xsl:when>
            </xsl:choose>
            <xsl:if test="$artnum != ''">, <span class="reflib_artnum"><xsl:value-of select="$artnum"/></span></xsl:if>
            <xsl:call-template name="url_identifier">
                <xsl:with-param name="url" select="$url"/>
                <xsl:with-param name="url2" select="$url2"/>
                <xsl:with-param name="identifier" select="$identifier"/>
                <xsl:with-param name="impact" select="notes"/>
                <xsl:with-param name="reprint" select="$reprint"/>
                <xsl:with-param name="date" select="$date"/>
            </xsl:call-template>
        </span>
    </li>
</xsl:template>

<xsl:template name="head_default">
    <head>
        <title>Publications - <xsl:if test="$ptitle != ''"><xsl:value-of select="$ptitle"/> - </xsl:if> <xsl:value-of select="title" /></title>
        <link rel="stylesheet" href="{$ximsroot}{$defaultcss}" type="text/css"/>
        <link rel="stylesheet" href="{$ximsroot}skins/{$currentskin}/stylesheets/vlibrary.css" type="text/css"/>
        <link rel="stylesheet" href="{$ximsroot}skins/{$currentskin}/stylesheets/reference_library.css" type="text/css"/>
        <link rel="stylesheet" href="{$css}" type="text/css"/>
        <link rel="stylesheet" href="http://www.uibk.ac.at/ionen-angewandte-physik/stylesheets/ionen.css" type="text/css"/>
        <script src="{$ximsroot}scripts/vlibrary_default.js" type="text/javascript"><xsl:text>&#160;</xsl:text></script>
        <script src="{$ximsroot}scripts/reflibrary.js" type="text/javascript"><xsl:text>&#160;</xsl:text></script>
        <script type="text/javascript">
function blocking(nr) {
    if (document.layers) {
        current = (document.layers[nr].display == 'none') ? 'block' : 'none';
        document.layers[nr].display = current;
    }
    else if (document.all) {
        current = (document.all[nr].style.display == 'none') ? 'block' : 'none';
        document.all[nr].style.display = current;
    }
    else if (document.getElementById) {
        vista = (document.getElementById(nr).style.display == 'none') ? 'block' : 'none';
        document.getElementById(nr).style.display = vista;
    }
}
        </script>
    </head>
</xsl:template>

</xsl:stylesheet>