<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.1">

 <xsl:import href="puccini.xsl"/>

    <xsl:template name="desc_crediti">
        
        <xsl:document href="{$path}/crediti-{$filename}.html">
            <html>
                <head>
                    <title>Centro Studi GIACOMO PUCCINI: <xsl:value-of select="$filename"/></title>
                    <link rel="stylesheet" type="text/css" media="screen" href="{$path_css}struttura.css"/>
                </head>
                <body>
                    <h4>Crediti</h4>
                    <div>
                        <b>Edizione a cura di</b> Gabriella Ravenni e Dieter Schickling <p>
                            <!--<b><xsl:apply-templates select="//fileDesc/titleStmt/respStmt/resp[@n='2']"/></b><br />
                                <b>Comitato editoriale:</b> Il gruppo di lavoro sull'epistolario è coordinato da Gabriella Biagi Ravenni (università di Pisa) ed è composto da Giulio Battelli (Istituto musicale «Luigi Boccherini», Lucca), Michele Girardi (Università di Pavia), Arthur Groos (Cornell University), Jürgen Maehder (Freie Universität Berlin), Peter Ross(Bern) e Dieter Schickling (Stuttgart)<br /><br />-->
                            <b>Trascrizione di</b> Simonetta Bigongiari e Gianmarco Caselli<!--<xsl:apply-templates
                                select="//fileDesc/titleStmt/respStmt/resp[@n='3']"/>--><br/><br/>
                            <b>Progetto di codifica a cura di </b><xsl:apply-templates
                                select="//fileDesc/titleStmt/respStmt/resp[@n='4']"/><br/><br/>
                            <!--<b>Codifica eseguita da </b> <xsl:apply-templates select="//revisionDesc//name"/>-->
                            <b>Codifica eseguita da</b> Serena Ferretti, Simona Minichelli e Jessica Profeti </p>
                    </div>
                </body>
                
            </html>
        </xsl:document>
        
    </xsl:template>

    <xsl:template name="link_crediti">
    <a href="javascript:;" onClick="window.open('crediti-{$filename}.html', 'titolo', 'width=400, height=300, resizable, status=0, scrollbars=no');">Crediti</a>
    <xsl:call-template name="desc_crediti"/>
    </xsl:template>
    
    <xsl:template name="crediti">
    </xsl:template>
    
    <xsl:template name="desc_fisica">    
        <xsl:document href="{$path}/desc-{$filename}.html">
            <html>
                <head>
                    <title>Centro Studi GIACOMO PUCCINI: <xsl:value-of select="$filename"/></title>
                    <link rel="stylesheet" type="text/css" media="screen" href="{$path_css}struttura.css"/>
                </head>
                <body>
                    <xsl:choose>
                        <xsl:when
                            test="//support//seg[@type!='tipo di supporto'] or //layout//seg[@type='foliazione'] or //musicNotation or /decoration or //extent[(.!='Non disponibili')] or //condition or //paraphernalia//paraphItem[not(@id='carta_intestata')][not(@id='busta_intestata')][not(@id='para1')]">
                            <br/>
                            <h3 style="text-align:center;">Descrizione documento</h3>
                                <p>
                                    <!-- visualizzazione foliazione e paginazione -->
                                    <xsl:if test="//physDesc//support//seg[@type='paginazione']">
                                        <xsl:value-of select="//physDesc//support//seg[@type='paginazione']"/>
                                    </xsl:if>                       
                                    <xsl:if test="//physDesc//layout//seg[@type='foliazione']">
                                        <xsl:text> </xsl:text>
                                        <xsl:value-of select="//physDesc//layout//seg[@type='foliazione']"/>
                                    </xsl:if>
                                    
                                    <!-- Visualizzazione musicNotation -->
                                    <xsl:if test="//physDesc//musicNotation"><xsl:choose>
                                        <xsl:when test="//physDesc//musicNotation and //physDesc/descendant-or-self::support//seg[@type='paginazione'] or //physDesc/descendant-or-self::layout//seg[@type='foliazione']">; <xsl:value-of select="//physDesc//musicNotation"/></xsl:when>
                                        <xsl:otherwise><xsl:value-of select="//physDesc//musicNotation"/></xsl:otherwise>
                                    </xsl:choose></xsl:if>
                                    
                                    <!-- Visualizzazione decoration -->
                                    <xsl:if test="//physDesc/decoration"><xsl:choose>
                                        <xsl:when test="//physDesc//decoration and //physDesc/descendant-or-self::support//seg[@type='paginazione'] or //physDesc/descendant-or-self::layout//seg[@type='foliazione'] or //physDesc/descendant-or-self::musicNotation">; <xsl:value-of select="//physDesc//decoration"/>
                                        </xsl:when>
                                        <xsl:otherwise><xsl:value-of select="//physDesc//decoration"/></xsl:otherwise>
                                    </xsl:choose></xsl:if>
                                    
                                    <!-- Visualizzazione carta -->
                                    <xsl:if test="//physDesc//seg[@type='colore carta']">
                                        <xsl:choose>
                                            <xsl:when test="//physDesc//seg[@type='colore carta'] and //physDesc/descendant-or-self::support//seg[@type='paginazione'] or //physDesc/descendant-or-self::layout//seg[@type='foliazione'] or //physDesc/descendant-or-self::musicNotation or //physDesc/descendant-or-self::decoration">; carta <xsl:value-of select="//physDesc//seg[@type='colore carta']"/>
                                            </xsl:when>
                                            <xsl:otherwise>carta <xsl:value-of select="//physDesc//seg[@type='colore carta']"/></xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:if>
                                    
                                    <!-- Visualizzazione inchiostro -->
                                    <xsl:if test="//physDesc//seg[@type='colore inchiostro']">
                                        <xsl:choose>
                                            <xsl:when test="//physDesc//seg[@type='colore inchiostro'] and //physDesc/descendant-or-self::support//seg[@type='paginazione'] or //physDesc/descendant-or-self::layout//seg[@type='foliazione'] or //physDesc/descendant-or-self::musicNotation or //physDesc/descendant-or-self::decoration or //physDesc/descendant-or-self::seg[@type='colore carta']">; inchiostro <xsl:value-of select="//physDesc//seg[@type='colore inchiostro']"/>
                                            </xsl:when>
                                            <xsl:otherwise>inchiostro <xsl:value-of select="//physDesc//seg[@type='colore inchiostro']"/></xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:if>
                                    
                                    <!-- Visualizzazione sigilli -->  
                                    <xsl:if test="//physDesc//seg[@type='sigilli']">
                                        <xsl:choose>
                                            <xsl:when test="//physDesc//seg[@type='sigilli'] and //physDesc/descendant-or-self::support//seg[@type='paginazione'] or //physDesc/descendant-or-self::layout//seg[@type='foliazione'] or //physDesc/descendant-or-self::musicNotation or //physDesc/descendant-or-self::decoration or //physDesc/descendant-or-self::seg[@type='colore carta'] or //physDesc/descendant-or-self::seg[@type='colore inchiostro']">; <xsl:value-of select="//physDesc//seg[@type='sigilli']"/>
                                            </xsl:when>
                                            <xsl:otherwise><xsl:value-of select="//physDesc//seg[@type='sigilli']"/></xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:if>
                                    
                                    <!-- Visualizzazione paraphernalia-->  
                                    <xsl:if
                                        test="//physDesc//paraphItem[@id!='carta_intestata'][@id!='busta_intestata'][@id!='para1']">
                                        <xsl:choose><xsl:when test="//physDesc//paraphItem[@id!='carta_intestata'][@id!='busta_intestata'][@id!='para1'] and //physDesc/descendant-or-self::support//seg[@type='paginazione'] or //physDesc/descendant-or-self::layout//seg[@type='foliazione'] or //physDesc/descendant-or-self::musicNotation or //physDesc/descendant-or-self::decoration or //physDesc/descendant-or-self::seg[@type='colore carta'] or //physDesc/descendant-or-self::seg[@type='colore inchiostro'] or //physDesc/descendant-or-self::seg[@type='sigilli']">; <xsl:value-of select="//physDesc//paraphItem[@id!='carta_intestata'][@id!='busta_intestata'][@id!='para1']"/></xsl:when>
                                            <xsl:otherwise><xsl:value-of select="//physDesc//paraphItem[@id!='carta_intestata'][@id!='busta_intestata'][@id!='para1']"/></xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:if>
                                    
                                    <!-- Visualizzazione dimensioni-->
                                    <xsl:if test="//physDesc/extent[(.!='Non disponibili')]">
                                        <xsl:choose>
                                            <xsl:when test="//physDesc/extent[(.!='Non disponibili')] and //physDesc/descendant-or-self::support//seg[@type='paginazione'] or //physDesc/descendant-or-self::layout//seg[@type='foliazione'] or //physDesc/descendant-or-self::musicNotation or //physDesc/descendant-or-self::decoration or //physDesc/descendant-or-self::seg[@type='colore carta'] or //physDesc/descendant-or-self::seg[@type='colore inchiostro'] or //physDesc/descendant-or-self::seg[@type='sigilli'] or //physDesc/descendant-or-self::paraphItem[@id!='carta_intestata'][@id!='busta_intestata'][@id!='para1']">; <xsl:value-of select="//physDesc/extent[(.!='Non disponibili')]"/>
                                            </xsl:when>
                                            <xsl:otherwise><xsl:value-of select="//physDesc/extent[(.!='Non disponibili')]"/></xsl:otherwise>
                                        </xsl:choose>                        
                                    </xsl:if>
                                    
                                    <!-- Visualizzazione condizioni-->
                                    <xsl:if test="//physDesc/condition">
                                        <xsl:choose><xsl:when test="//physDesc/condition and //physDesc/descendant-or-self::support//seg[@type='paginazione'] or //physDesc/descendant-or-self::layout//seg[@type='foliazione'] or //physDesc/descendant-or-self::musicNotation or //physDesc/descendant-or-self::decoration or //physDesc/descendant-or-self::seg[@type='colore carta'] or //physDesc/descendant-or-self::seg[@type='colore inchiostro'] or //physDesc/descendant-or-self::seg[@type='sigilli'] or //physDesc/descendant-or-self::paraphItem[@id!='carta_intestata'][@id!='busta_intestata'][@id!='para1'] or //physDesc/descendant-or-self::extent[(.!='Non disponibili')]">; <xsl:value-of select="//physDesc/condition"/></xsl:when>
                                            <xsl:otherwise><xsl:value-of select="//physDesc/condition"/></xsl:otherwise>
                                        </xsl:choose>        
                                    </xsl:if>
                                    
                                    <!-- Visualizzazione annotazioni-->
                                    <xsl:if test="//physDesc//seg[@type='annotazioni']">
                                        <xsl:choose>
                                            <xsl:when test="//physDesc//seg[@type='annotazioni'] and //physDesc/descendant-or-self::support//seg[@type='paginazione'] or //physDesc/descendant-or-self::layout//seg[@type='foliazione'] or //physDesc/descendant-or-self::musicNotation or //physDesc/descendant-or-self::decoration or //physDesc/descendant-or-self::seg[@type='colore carta'] or //physDesc/descendant-or-self::seg[@type='colore inchiostro'] or //physDesc/descendant-or-self::seg[@type='sigilli'] or //physDesc/descendant-or-self::paraphItem[@id!='carta_intestata'][@id!='busta_intestata'][@id!='para1'] or //physDesc/descendant-or-self::extent[(.!='Non disponibili')] or //physDesc/descendant-or-self::condition">; <xsl:value-of select="//physDesc//seg[@type='annotazioni']"/>
                                            </xsl:when>
                                            <xsl:otherwise><xsl:value-of select="//physDesc//seg[@type='annotazioni']"/></xsl:otherwise>
                                        </xsl:choose>
                                        
                                    </xsl:if>
                                </p>
                        </xsl:when>
                        <xsl:otherwise/>
                    </xsl:choose>
                </body>
            </html>
        </xsl:document>
    </xsl:template>
    
    <xsl:template name="link_desc">
        <br /><a href="javascript:;" onClick="window.open('desc-{$filename}.html', 'titolo', 'width=400, height=300, resizable, status=0, scrollbars=no');">Descizione documento</a>
        <xsl:call-template name="desc_fisica"/>
    </xsl:template>
    
    <xsl:template name="descrizione">
    </xsl:template>
    
    
    <xsl:template name="descPOP_storia">
        
        <xsl:document href="{$path}/storia-{$filename}.html">
            <html>
                <head>
                    <title>Centro Studi GIACOMO PUCCINI: <xsl:value-of select="$filename"/></title>
                    <link rel="stylesheet" type="text/css" media="screen" href="struttura.css"/>
                    
                </head><body>
                    <xsl:if test="//seg[@type='reference number']">
                        <!-- <xsl:if test="//seg[@type='reference number']">-->
                        <b>Timbri di protocollo:</b>
                        
                            <xsl:for-each select="//seg[@type='reference number']">
                                
                                <p><xsl:apply-templates/></p>
                                
                            </xsl:for-each>
                        
                        <!--</xsl:if>-->
                    </xsl:if>
                    
                    <!-- <xsl:if test="//history/note">-->
                    <xsl:if test="//history/note or //envelope//note">
                        <br/>
                        <b>Annotazioni: </b>
                        
                            <xsl:for-each select="//history/note">
                                
                                <p><xsl:apply-templates/></p>
                                
                            </xsl:for-each>
                        
                        <!--</xsl:if>-->
                    </xsl:if>
                    <!-- Visualizzato solo nell'edizione comitato -->
                    <xsl:if test="//history/provenance">
                        <br/>
                        <b>Passaggi di proprietà: (visualizzato solo per l'edizione "comitato")</b>
                        <ul>
                            <xsl:for-each select="//history/provenance">
                                <li>
                                    <xsl:apply-templates select="."/>
                                </li>
                            </xsl:for-each>
                        </ul>
                        <!--</xsl:if>-->
                    </xsl:if>
                </body>
                </html>
        </xsl:document>
        
    </xsl:template>
    
    <xsl:template name="link_storia">
        <br/><a href="javascript:;" onClick="window.open('storia-{$filename}.html', 'titolo', 'width=400, height=300, resizable, status=0, scrollbars=no');">Storia del documento</a>
        <xsl:call-template name="descPOP_storia"/>
    </xsl:template>
    
    <xsl:template name="desc_storia">
    </xsl:template>
    
    
    <xsl:template name="img_cartaIntestata">
    </xsl:template>
    
       <xsl:template name="link_cartaIntestata">   
             <!--   <xsl:if test="//paraphItem/@id">
            <xsl:choose>
                <xsl:when
                    test="//paraphItem[@id='carta_intestata'] or //paraphItem[@id='busta_intestata']">
                    <xsl:if test="//paraphItem[@id='carta_intestata']">
                        <i>
                            <xsl:text> </xsl:text><a target="_blank"><xsl:attribute name="href">img/carte_intestate/<xsl:apply-templates select="//paraphItem[@id='carta_intestata']/paraphDesc//xref/@to" />.jpg</xsl:attribute><xsl:apply-templates
                                select="//paraphItem[@id='carta_intestata']/paraphText//text()"/></a>
                        </i>
                    </xsl:if>
                    <xsl:if
                        test="//paraphItem[@id='busta_intestata'] and //physDesc/type[(.!='Lettera con busta')]">
                        <xsl:text> </xsl:text>con busta intestata <a target="_blank"><xsl:attribute name="href">img/carte_intestate/<xsl:apply-templates select="//paraphItem[@id='busta_intestata']/paraphDesc//xref/@to" />.jpg</xsl:attribute><xsl:apply-templates
                            select="//paraphItem[@id='busta_intestata']/paraphText"/></a>
                    </xsl:if>
                    <xsl:if
                        test="//paraphItem[@id='busta_intestata'] and //physDesc/type[(.='Lettera con busta')]">
                        <xsl:text> </xsl:text>
                        <a target="_blank"><xsl:attribute name="href">img/carte_intestate/<xsl:apply-templates select="//paraphItem[@id='busta_intestata']/paraphDesc//xref/@to" />.jpg</xsl:attribute><xsl:apply-templates select="//paraphItem[@id='busta_intestata']/paraphText"
                        /></a>
                    </xsl:if>
                </xsl:when>
            </xsl:choose>
                 </xsl:if>-->           
           
           <xsl:if test="//paraphItem/@id">
               <xsl:choose>            
                   <xsl:when
                       test="//paraphItem[@id='carta_intestata'] and //paraphItem[@id='busta_intestata']"><i><a target="_blank"><xsl:attribute name="href">img/carte_intestate/<xsl:apply-templates select="//paraphItem[@id='carta_intestata']/paraphDesc//xref/@to" />.jpg</xsl:attribute><xsl:apply-templates
                               select="//paraphItem[@id='carta_intestata']/paraphText//text()"/></a>
                       </i>  
                       e busta intestata <i><a target="_blank"><xsl:attribute name="href">img/carte_intestate/<xsl:apply-templates select="//paraphItem[@id='busta_intestata']/paraphDesc//xref/@to" />.jpg</xsl:attribute><xsl:apply-templates
                           select="//paraphItem[@id='busta_intestata']/paraphText//text()"/></a></i>
                   </xsl:when>
                   <xsl:when
                       test="//paraphItem[@id='carta_intestata'] or //paraphItem[@id='busta_intestata']">
                       <xsl:if test="//paraphItem[@id='carta_intestata']"><i><a target="_blank"><xsl:attribute name="href">img/carte_intestate/<xsl:apply-templates select="//paraphItem[@id='carta_intestata']/paraphDesc//xref/@to" />.jpg</xsl:attribute><xsl:apply-templates
                                   select="//paraphItem[@id='carta_intestata']/paraphText//text()"/></a>
                           </i>
                       </xsl:if>
                       <xsl:if
                           test="//paraphItem[@id='busta_intestata'] and //physDesc/type[(.!='Lettera con busta')]">
                           <xsl:text> </xsl:text>con busta intestata <i><a target="_blank"><xsl:attribute name="href">img/carte_intestate/<xsl:apply-templates select="//paraphItem[@id='busta_intestata']/paraphDesc//xref/@to" />.jpg</xsl:attribute><xsl:apply-templates
                               select="//paraphItem[@id='busta_intestata']/paraphText//text()"/></a></i>
                       </xsl:if>
                       <xsl:if
                           test="//paraphItem[@id='busta_intestata'] and //physDesc/type[(.='Lettera con busta')]">
                           <xsl:text> </xsl:text> <i><a target="_blank"><xsl:attribute name="href">img/carte_intestate/<xsl:apply-templates select="//paraphItem[@id='busta_intestata']/paraphDesc//xref/@to" />.jpg</xsl:attribute><xsl:apply-templates
                               select="//paraphItem[@id='busta_intestata']/paraphText//text()"/></a></i>
                       </xsl:if>
                   </xsl:when>
               </xsl:choose>
           </xsl:if>
           
    </xsl:template>
    
    <xsl:template name="descarta_intestata">
    </xsl:template>

</xsl:stylesheet>
