<!-- 
Visualizzatore METS
     Angela Di Iorio, S.I.M.B.A.D. tool for Digital Library P. Albino
	 
     bibliotecadigitale@provincia.campobasso.it
     2 Aprile 2004 
     Version 1.0  
  --> 
<!-- 
 Copyright (c) 2004 BIBLIOTECA PROVINCIALE "P. ALBINO"
     Permission is hereby granted, without written agreement and without
     license or royalty fees, to use, copy, modify, and distribute this XSLT
     style sheet for any purpose, provided that the above copyright notice
     and the following two paragraphs appear in all copies of this
     document.

     IN NO EVENT SHALL BIBLIOTECA PROVINCIALE "P. ALBINO" BE LIABLE TO ANY PARTY
     FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
     ARISING OUT OF THE USE OF THIS COMPUTER FILE, EVEN IF BIBLIOTECA PROVINCIALE "P. ALBINO" HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
     DAMAGE.

     BIBLIOTECA PROVINCIALE "P. ALBINO" SPECIFICALLY DISCLAIMS ANY WARRANTIES,
     INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE COMPUTER
     FILE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND BIBLIOTECA PROVINCIALE "P. ALBINO" HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
     SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.  

  --> 
<xsl:stylesheet
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
   xmlns:mag="http://www.iccu.sbn.it/metaAG1.pdf" 
   xmlns:xlink="http://www.w3.org/TR/xlink"
   xmlns:dc="http://purl.org/dc/elements/1.1/" version="1.0"
   xmlns:mix="http://www.loc.gov/mix/"
   xmlns:mets="http://www.loc.gov/mets/"
   xsi:schemaLocation="http://www.iccu.sbn.it/metaAG1.pdf metadigit.xsd http://www.loc.gov/METS/ 
   http://www.loc.gov/standards/mets/mets.xsd http://www.loc.gov/standards/mix/mix.xsd">
<xsl:import href="intermedio.xsl"/> 
<xsl:template match="/"> 
    <xsl:apply-templates select="rdf:RDF"/> 
</xsl:template> 

<xsl:template match="rdf:RDF">
  <html>
    <head>
		<xsl:element name="link">
			<xsl:attribute name="rel">stylesheet</xsl:attribute>
	    	<xsl:attribute name="type">text/css</xsl:attribute>
			<xsl:attribute name="href"><xsl:value-of select="$url"/>css/mets.css</xsl:attribute>
   		</xsl:element>
        <title><xsl:value-of select="//dc:title"/></title>
    </head>
      <body bgcolor="000000" topmargin="0">
		<xsl:variable name="setdata">
			<xsl:value-of select="$urlcat"/><xsl:value-of select="//mets:amdSec/@ID"/>
			<xsl:text>/</xsl:text><xsl:value-of select="//mets:metsHdr/@ID"/><xsl:text>.xml</xsl:text>
		</xsl:variable>

		<xsl:variable name="sezdescr">
			<xsl:if test="count(//mets:admSec/mets:sourceMD/@ID) > '1'" >
				<xsl:value-of select="//mets:amdSec/mets:sourceMD[last()-1]/@ID"/><xsl:text>.xml</xsl:text>
			</xsl:if>
		</xsl:variable>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td rowspan="5" width="17%">
	<xsl:element name="a">
		<xsl:attribute name="href"><xsl:value-of select="$url"/>index.html</xsl:attribute>
		<xsl:element name="img">
			<xsl:attribute name="src"><xsl:value-of select="$url"/>immagini/logo3.jpg</xsl:attribute>
	    	<xsl:attribute name="border">0</xsl:attribute>
			<xsl:attribute name="alt">Biblioteca Digitale Provinciale P.Albino</xsl:attribute>
   		</xsl:element>
	</xsl:element>
</td>
<th class="lem14">
	<xsl:element name="a">
	<xsl:attribute name="href"><xsl:value-of select="$url"/>index.html</xsl:attribute>
   	<xsl:attribute name="class">home</xsl:attribute>
	Biblioteca Digitale Provinciale P.Albino
	</xsl:element>
</th>
<td id="visualmets">Visualizzatore XSL compatibile allo
<a href="http://www.loc.gov/standards/mets/" id="linkmets" target="_blank">Standard METS</a></td>
</tr>
<tr>
<td></td>
<td id="visualmets">Set data: <xsl:value-of select="//mets:metsHdr/@ID"/></td>
</tr>
<tr>
<th class="cardo12">Fondo:<strong class="dim10"><xsl:value-of select="document($setdata)//dc:title"/></strong></th>
<td id="visualmets">
    <xsl:if test = "not ((count(//mets:sourceMD/@ID) = '1' and //mag:stru/@start = '1') and //mag:stru/@stop = '1')">
		<xsl:text>livello di aggregazione: </xsl:text><xsl:value-of select="//mets:sourceMD/@ID"/>
	</xsl:if>
</td>
</tr>
<tr>
<td></td>
<td id="visualmets">
<xsl:if test = "count(//mets:sourceMD/@ID) > '2'">
	<xsl:text>livelli intermedi:</xsl:text>
	<xsl:for-each select = "//mets:sourceMD/@ID" >
		<xsl:if test="not(position()='1' or position()=last())"> 
			<xsl:text> </xsl:text><xsl:value-of select="."/>
		</xsl:if>
	</xsl:for-each>
</xsl:if> 
</td>
</tr>
<tr>
<td></td>
<td id="visualmets">
<xsl:for-each select = "//mets:sourceMD/@ID" >
	<xsl:if test="position()=last()"> 
		<xsl:text>oggetto finale: </xsl:text><xsl:value-of select="."/>
	</xsl:if>
</xsl:for-each>

</td>
</tr>
</table>

<table>
<tr>
<!-- <xsl:apply-templates select="//mets:structMap" /> -->
<xsl:call-template name="mappagruppi" />
</tr></table>
		<xsl:call-template name="sfogliomappina" />
		<hr border="0" />
		<xsl:apply-templates select="//mets:fileGrp" />
		<hr border="0" />
		<xsl:if test="$sezdescr">		
			<xsl:if test="document($sezdescr)//mag:year">
				<div class="cardo9"><xsl:text>Anno: </xsl:text>
				<em class="lem12"><xsl:value-of select="document($sezdescr)//mag:year"/></em></div>
			</xsl:if>
			<xsl:if test="document($sezdescr)//mag:issue">
				<div class="cardo9"><xsl:text> Num.: </xsl:text>
				<em class="lem12"><xsl:value-of select="document($sezdescr)//mag:issue"/></em></div>
			</xsl:if>
		</xsl:if>
		<xsl:if test="not(//mets:dmdSec/mets:mdRef/@xlink:href)">
			<xsl:apply-templates select="//mets:dmdSec/mets:mdWrap/mets:xmlData" />
		</xsl:if>
		<xsl:if test="//mets:dmdSec/mets:mdRef/@xlink:href"> 
			<xsl:call-template name="descrittivi" />
		</xsl:if>
		<hr border="0" />
		<xsl:apply-templates select="//mets:metsHdr" />
     </body>
  </html>
</xsl:template>
<xsl:template match = "//mets:fileGrp" >
<table width="95%" cellpadding="0" cellspacing="4" align="center">
	<xsl:if test = "@ID='CD'">
		<tr><td colspan="2" width="20%" class="mintcream10">Provenienza oggetto dal CD:</td><td><xsl:value-of select="//mix:ImageIdentifier"/></td></tr>
	</xsl:if>
	<tr><td>
		<xsl:element name="a">
			<xsl:attribute name="href"><xsl:value-of select="//mets:fileGrp/mets:file[@ID='JPG']/mets:FLocat/@xlink:href"/></xsl:attribute>
			<xsl:attribute name="target">_blank</xsl:attribute>
			<xsl:attribute name="class">orange10</xsl:attribute>
			<xsl:element name="img">
				<xsl:attribute name="src"><xsl:value-of select="//mets:fileGrp/mets:file[@ID='JPGSMALL']/mets:FLocat/@xlink:href"/>
				</xsl:attribute>
				<xsl:attribute name="border">3</xsl:attribute>
				<xsl:attribute name="alt">cliccando visualizza l'immagine grande</xsl:attribute>
			</xsl:element>
		</xsl:element>
	</td>
	<td><xsl:element name="img">
			<xsl:attribute name="src"><xsl:value-of select="//mets:fileGrp/mets:file[@ID='JPGRID']/mets:FLocat/@xlink:href"/></xsl:attribute>
			<xsl:attribute name="border">0</xsl:attribute>
		</xsl:element>
	</td></tr>
</table>
</xsl:template>
<xsl:template name="sfogliomappina">
<xsl:variable name="sonoio">
	<xsl:value-of select="//mets:amdSec/mets:sourceMD[last()]/@ID"/><xsl:text>.xml</xsl:text>
</xsl:variable>
<table>
<tr><td class="lem10">Pagine: </td>
<xsl:for-each select="//mets:div">
	<xsl:if test = "not(substring(@ID,1,3)='pre' or substring(@ID,1,3)='suc' or substring(@ID,1,3)='ord')">
		<xsl:variable name="crea" select="@ID"  />
		<xsl:if test="not(//mets:file[@ID=$crea]/mets:FLocat/@xlink:href =$sonoio)">
		<td>
		<xsl:element name="a">
		    <xsl:attribute name="href">
			   <xsl:value-of select="//mets:file[@ID=$crea]/mets:FLocat/@xlink:href"/>
			</xsl:attribute>
	    	<xsl:attribute name="class">sfoglio</xsl:attribute>
		    <xsl:value-of select="@LABEL" />
   		</xsl:element>
		</td><td>---</td>
		</xsl:if>
	</xsl:if>
</xsl:for-each>

</tr></table>
</xsl:template>
<xsl:template name="mappagruppi">
<xsl:for-each select="//mets:div">
<td>
<xsl:choose> 
	<xsl:when test = "substring(@ID,1,3)='ord'">
		<xsl:variable name="crea" select="@ID"  />
		<xsl:element name="a">
		    <xsl:attribute name="href">
			   <xsl:value-of select="//mets:file[@ID=$crea]/mets:FLocat/@xlink:href"/>
			</xsl:attribute>
	    	<xsl:attribute name="class">barsup</xsl:attribute>
		    <xsl:value-of select="@LABEL" />
   		</xsl:element>
	</xsl:when>
	<xsl:when test = "(substring(@ID,1,3)='pre' or substring(@ID,1,3)='suc')">
		<xsl:variable name="crea" select="@ID"  />
		<xsl:element name="a">
		    <xsl:attribute name="href">
			   <xsl:value-of select="//mets:file[@ID=$crea]/mets:FLocat/@xlink:href"/>
			</xsl:attribute>
	    	<xsl:attribute name="class">barnav</xsl:attribute>
		    <xsl:value-of select="@LABEL" /> 
   		</xsl:element>
	</xsl:when>
</xsl:choose> 
</td><td>---</td>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
