<?xml version="1.0" encoding="UTF-8"?>

<!-- 
    Project: Moralische Wochenschriften, Institut für Romanistik, Universität Graz
    Company: ZIM:IG (Zentrum für Informationsmodellierung in den Geisteswissenschaften)
    Author: Martina Semlak
    Last update: 20-08-2012   
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:i18n="http://apache.org/cocoon/i18n/2.1" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
        xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:java="http://xml.apache.org/xslt/java" exclude-result-prefixes="java" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:oai="http://www.openarchives.org/OAI/2.0/" xmlns:s="http://www.w3.org/2001/sw/DataAccess/rf1/result" xmlns:t="http://www.tei-c.org/ns/1.0">
       
        <xsl:param name="locale"/>
        <xsl:param name="mode"/>
        
         
        
        <xsl:strip-space elements="*"/>
       
       
        <xsl:variable name="idno">
        <xsl:choose>
            <xsl:when test="contains(//t:idno, 'info:fedora')">
                <xsl:value-of select="substring-after(//t:idno, '/')" />
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="//t:idno" />
            </xsl:otherwise>
        </xsl:choose>
    </xsl:variable>
  
       
        <xsl:variable name="handle">
        <xsl:value-of
            select="document(concat('http://gams.uni-graz.at/archive/objects/', $idno, '/datastreams/RELS-EXT/content'))//rdf:RDF/rdf:Description/oai:itemID"
        />
    </xsl:variable>
             
     <xsl:variable name="vLowest">
        <xsl:for-each select="//t:pb/@n">
            <xsl:sort data-type="number"/>
            <xsl:if test="position() = 1">
                <xsl:value-of select="."/>
            </xsl:if>
        </xsl:for-each>
    </xsl:variable>
    <xsl:variable name="vHighest">
        <xsl:for-each select="//t:pb/@n">
            <xsl:sort data-type="number"/>
            <xsl:if test="position() = last()">
                <xsl:value-of select="."/>
            </xsl:if>
        </xsl:for-each>
    </xsl:variable>
  
  
                        
        
        
        <!--Formatierungsangaben für Überschriften-->
        <xsl:attribute-set name="title">
            <xsl:attribute name="font-family">GaramondURW, serif</xsl:attribute>
            <xsl:attribute name="font-size">14pt</xsl:attribute>
            <xsl:attribute name="text-align">left</xsl:attribute>
            <xsl:attribute name="padding-top">5px</xsl:attribute>
            <xsl:attribute name="padding-bottom">3px</xsl:attribute>
            <xsl:attribute name="color">#000000</xsl:attribute>
            <xsl:attribute name="text-transform">uppercase</xsl:attribute>
        </xsl:attribute-set>
    
        <xsl:attribute-set name="subtitle">
            <xsl:attribute name="font-family">GaramondURW, serif</xsl:attribute>
            <xsl:attribute name="font-size">12pt</xsl:attribute>
            <xsl:attribute name="text-align">left</xsl:attribute>
            <xsl:attribute name="padding-bottom">3px</xsl:attribute>
            <xsl:attribute name="color">#000000</xsl:attribute>
        </xsl:attribute-set>
        
        <xsl:attribute-set name="memberTitle">
            <xsl:attribute name="font-family">GaramondURW, serif</xsl:attribute>
            <xsl:attribute name="font-size">10pt</xsl:attribute>
            <xsl:attribute name="text-align">left</xsl:attribute>
            <xsl:attribute name="font-style">italic</xsl:attribute>
            <xsl:attribute name="padding-right">0px</xsl:attribute>
            <xsl:attribute name="padding-bottom">5px</xsl:attribute>
            <xsl:attribute name="padding-top">2px</xsl:attribute>
        </xsl:attribute-set>
    
    <xsl:attribute-set name="U1">
        <xsl:attribute name="font-family">GaramondURW, serif</xsl:attribute>
        <xsl:attribute name="font-size">12pt</xsl:attribute>
        <xsl:attribute name="font-weight">bold</xsl:attribute>
        <xsl:attribute name="space-before">0cm</xsl:attribute>
        <xsl:attribute name="space-after">0.6cm</xsl:attribute>
        <xsl:attribute name="text-align">center</xsl:attribute>
        <xsl:attribute name="keep-with-next">always</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="U2">
        <xsl:attribute name="font-size">12pt</xsl:attribute>
        <xsl:attribute name="font-family">GaramondURW, serif</xsl:attribute>
        <xsl:attribute name="space-before">0.6cm</xsl:attribute>
        <xsl:attribute name="space-after">0.4cm</xsl:attribute>
        <xsl:attribute name="text-align">center</xsl:attribute>
        <xsl:attribute name="keep-with-next">always</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="U3">
        <xsl:attribute name="font-size">11pt</xsl:attribute>
        <xsl:attribute name="font-family">GaramondURW, serif</xsl:attribute>
        <xsl:attribute name="space-before">0.6cm</xsl:attribute>
        <xsl:attribute name="space-after">0.6cm</xsl:attribute>
        <xsl:attribute name="text-align">center</xsl:attribute>
        <xsl:attribute name="keep-with-next">always</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="MO">
        <xsl:attribute name="font-size">11pt</xsl:attribute>
        <xsl:attribute name="font-family">GaramondURW, serif</xsl:attribute>
        <xsl:attribute name="font-style">italic</xsl:attribute>
        <xsl:attribute name="space-before">0cm</xsl:attribute>
        <xsl:attribute name="space-after">0.4cm</xsl:attribute>
        <xsl:attribute name="text-align">center</xsl:attribute>
        <xsl:attribute name="keep-with-next">always</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="QU">
        <xsl:attribute name="font-size">11pt</xsl:attribute>
        <xsl:attribute name="font-family">GaramondURW, serif</xsl:attribute>
        <xsl:attribute name="space-before">0cm</xsl:attribute>
        <xsl:attribute name="space-after">0.6cm</xsl:attribute>
        <xsl:attribute name="text-align">center</xsl:attribute>
        <xsl:attribute name="keep-with-next">always</xsl:attribute>
    </xsl:attribute-set>

    <xsl:attribute-set name="UM">
        <xsl:attribute name="font-size">11pt</xsl:attribute>
        <xsl:attribute name="font-family">GaramondURW, serif</xsl:attribute>
        <xsl:attribute name="space-before">0cm</xsl:attribute>
        <xsl:attribute name="space-after">0.6cm</xsl:attribute><!--<xsl:attribute name="space-after">0.12cm</xsl:attribute>-->
        <xsl:attribute name="text-align">center</xsl:attribute>
        <xsl:attribute name="keep-with-next">always</xsl:attribute>
    </xsl:attribute-set>

    <xsl:attribute-set name="SO">
        <xsl:attribute name="font-size">11pt</xsl:attribute>
        <xsl:attribute name="font-family">GaramondURW, serif</xsl:attribute>
        <xsl:attribute name="text-indent">0</xsl:attribute><!-- 0.5 -->
        <xsl:attribute name="space-before">0cm</xsl:attribute>
        <xsl:attribute name="space-after">0.4cm</xsl:attribute>
        <xsl:attribute name="text-align">justify</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="ST">
        <xsl:attribute name="font-size">11pt</xsl:attribute>
        <xsl:attribute name="font-family">GaramondURW, serif</xsl:attribute>
        <xsl:attribute name="text-indent">0.5cm</xsl:attribute>
        <xsl:attribute name="space-before">0cm</xsl:attribute>
        <xsl:attribute name="space-after">0cm</xsl:attribute><!-- 0.4cm -->
        <xsl:attribute name="text-align">justify</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="DT">
        <xsl:attribute name="font-size">11pt</xsl:attribute>
        <xsl:attribute name="font-family">GaramondURW, serif</xsl:attribute>
        <xsl:attribute name="space-before">0cm</xsl:attribute>
        <xsl:attribute name="space-after">0.2cm</xsl:attribute>
        <xsl:attribute name="text-align">center</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="BA">
        <xsl:attribute name="font-size">11pt</xsl:attribute>
        <xsl:attribute name="font-family">GaramondURW, serif</xsl:attribute>
        <xsl:attribute name="space-before">0.6cm</xsl:attribute>
        <xsl:attribute name="space-after">0.4cm</xsl:attribute>
        <xsl:attribute name="text-align">center</xsl:attribute>
        <xsl:attribute name="keep-with-next">always</xsl:attribute>
    </xsl:attribute-set>

    <xsl:attribute-set name="BU">
        <xsl:attribute name="font-size">11pt</xsl:attribute>
        <xsl:attribute name="font-family">GaramondURW, serif</xsl:attribute>
        <xsl:attribute name="space-before">0.4cm</xsl:attribute>
        <xsl:attribute name="space-after">0.6cm</xsl:attribute>
        <xsl:attribute name="text-align">right</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="CI">
        <xsl:attribute name="font-size">11pt</xsl:attribute>
        <xsl:attribute name="font-family">LeedsUniExt, serif</xsl:attribute>
        <xsl:attribute name="text-indent">0.5cm</xsl:attribute>
        <xsl:attribute name="space-before">0cm</xsl:attribute>
        <xsl:attribute name="space-after">0.4cm</xsl:attribute>
        <xsl:attribute name="text-align">justify</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="lg">
        <xsl:attribute name="font-size">11pt</xsl:attribute>
        <xsl:attribute name="font-family">LeedsUniExt, serif</xsl:attribute>
        <xsl:attribute name="space-before">0.4cm</xsl:attribute>
        <xsl:attribute name="space-after">0.6cm</xsl:attribute>
        <xsl:attribute name="text-align">left</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="list">
        <xsl:attribute name="font-size">11pt</xsl:attribute>
        <xsl:attribute name="font-family">GaramondURW, serif</xsl:attribute>
        <xsl:attribute name="text-align">left</xsl:attribute>
        <xsl:attribute name="space-before">0.4cm</xsl:attribute>
        <xsl:attribute name="space-after">0.4cm</xsl:attribute>
        
    </xsl:attribute-set>
    
    <xsl:attribute-set name="G1">
        <xsl:attribute name="font-size">11pt</xsl:attribute>
        <xsl:attribute name="font-family">GaramondURW, serif</xsl:attribute>
        <xsl:attribute name="text-align">left</xsl:attribute>
        <xsl:attribute name="keep-with-next">always</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="GF">
        <xsl:attribute name="font-size">11pt</xsl:attribute>
        <xsl:attribute name="font-family">GaramondURW, serif</xsl:attribute>
        <xsl:attribute name="text-align">left</xsl:attribute>
        <xsl:attribute name="text-indent">0.5cm</xsl:attribute>
        <xsl:attribute name="keep-with-next">always</xsl:attribute>
    </xsl:attribute-set>
    
    
    
    <xsl:attribute-set name="italic">
    	<xsl:attribute name="font-style">italic</xsl:attribute>
    </xsl:attribute-set>
    
    <!-- FIXME: smallcaps funktioniert mit Apache FOP nicht, Alternative überlegen -->
    <xsl:attribute-set name="smallcaps">
    	<xsl:attribute name="text-transform">uppercase</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="superscript">
    	<xsl:attribute name="vertical-align">super</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="perma">
    	<xsl:attribute name="font-size">9pt</xsl:attribute>
        <xsl:attribute name="font-family">GaramondURW, serif</xsl:attribute>
    	<xsl:attribute name="text-align">right</xsl:attribute>
        <xsl:attribute name="padding-top">0.1cm</xsl:attribute>
    </xsl:attribute-set>

<xsl:attribute-set name="quotation">
    	<xsl:attribute name="font-size">9pt</xsl:attribute>
        <xsl:attribute name="font-family">GaramondURW, serif</xsl:attribute>
    	<xsl:attribute name="text-align">left</xsl:attribute>
        <xsl:attribute name="padding-top">0.1cm</xsl:attribute>
        <xsl:attribute name="padding-bottom">0.5cm</xsl:attribute>
    </xsl:attribute-set>

    
    <xsl:attribute-set name="pagenumber">
        <xsl:attribute name="font-size">9pt</xsl:attribute>
        <xsl:attribute name="font-family">GaramondURW, serif</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="seiten">
        <xsl:attribute name="font-family">GaramondURW, serif</xsl:attribute>
        <xsl:attribute name="font-size">11pt</xsl:attribute>
        <xsl:attribute name="padding-top">0.05cm</xsl:attribute>
        <xsl:attribute name="padding-left">0.05cm</xsl:attribute>
        <xsl:attribute name="padding-right">0.05cm</xsl:attribute>
        <xsl:attribute name="font-style">normal</xsl:attribute>
        <xsl:attribute name="background-color">yellow</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="milestone">
        <xsl:attribute name="font-family">GaramondURW, serif</xsl:attribute>
        <xsl:attribute name="font-size">11pt</xsl:attribute>
        <xsl:attribute name="padding-top">0.05cm</xsl:attribute>
        <xsl:attribute name="padding-left">0.05cm</xsl:attribute>
        <xsl:attribute name="padding-right">0.05cm</xsl:attribute>
        <xsl:attribute name="font-style">normal</xsl:attribute>
        <xsl:attribute name="text-transform">none</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="E1">
    	<xsl:attribute name="color">#000000</xsl:attribute>
        <xsl:attribute name="background-color">#eeeeee</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="E2">
    	<xsl:attribute name="background-color">#bbbbbb</xsl:attribute>
        <xsl:attribute name="color">#000000</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="E3">
    	<xsl:attribute name="background-color">#888888</xsl:attribute>
    	<xsl:attribute name="color">#ffffff</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="E4">
    	<xsl:attribute name="background-color">#555555</xsl:attribute>
    	<xsl:attribute name="color">#ffffff</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="E5">
        <xsl:attribute name="background-color">#222222</xsl:attribute>
    	<xsl:attribute name="color">#ffffff</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="E6">
        <xsl:attribute name="background-color">#000000</xsl:attribute>
        <xsl:attribute name="color">#ffffff</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="AL">
        <xsl:attribute name="background-color">#ffcc00</xsl:attribute>
        <xsl:attribute name="color">#000000</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="AE">
        <xsl:attribute name="background-color">#f49927</xsl:attribute>
        <xsl:attribute name="color">#ffffff</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="D">
        <xsl:attribute name="background-color">#e83227</xsl:attribute>
        <xsl:attribute name="color">#ffffff</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="EX">
        <xsl:attribute name="background-color">#990000</xsl:attribute>
        <xsl:attribute name="color">#ffffff</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="F">
        <xsl:attribute name="background-color">#eb268f</xsl:attribute>
        <xsl:attribute name="color">#ffffff</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="FP">
        <xsl:attribute name="background-color">#972e8a</xsl:attribute>
        <xsl:attribute name="color">#ffffff</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="LB">
        <xsl:attribute name="background-color">#0072b1</xsl:attribute>
        <xsl:attribute name="color">#ffffff</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="MT">
        <xsl:attribute name="background-color">#352683</xsl:attribute>
        <xsl:attribute name="color">#ffffff</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="S">
        <xsl:attribute name="background-color">#01a7e5</xsl:attribute>
        <xsl:attribute name="color">#000000</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="SP">
        <xsl:attribute name="background-color">#00a3a0</xsl:attribute>
        <xsl:attribute name="color">#ffffff</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="TR">
        <xsl:attribute name="background-color">#666633</xsl:attribute>
        <xsl:attribute name="color">#ffffff</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="UT">
        <xsl:attribute name="background-color">#00a052</xsl:attribute>
        <xsl:attribute name="color">#ffffff</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name="ZM">
        <xsl:attribute name="background-color">#77c33d</xsl:attribute>
        <xsl:attribute name="color">#ffffff</xsl:attribute>
    </xsl:attribute-set>
    
    
        <xsl:template match="t:TEI">
            <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
                <fo:layout-master-set>
                    
                    <fo:simple-page-master 
                        master-name="firstPage" 
                        page-width="210mm" 
                        page-height="297mm"
                        margin-top="15mm" 
                        margin-bottom="15mm" 
                        margin-left="20mm" 
                        margin-right="20mm">
                        <fo:region-body margin-bottom="20mm" margin-top="25mm" />
                        <fo:region-before region-name="firstBefore" extent="25mm"/>
                        <fo:region-after region-name="firstAfter" extent="10mm" />
                    </fo:simple-page-master>
                    <fo:simple-page-master 
                        master-name="rest" 
                        page-width="210mm" 
                        page-height="297mm"
                        margin-top="15mm" 
                        margin-bottom="15mm" 
                        margin-left="20mm" 
                        margin-right="20mm">
                        <fo:region-body margin-bottom="20mm" margin-top="10mm" />
                        
                        <fo:region-after region-name="restAfter" extent="10mm" />
                    </fo:simple-page-master>
                    <fo:page-sequence-master master-name="global">
                        <fo:repeatable-page-master-alternatives>
                            <fo:conditional-page-master-reference master-reference="firstPage" page-position="first"/>
                            <fo:conditional-page-master-reference master-reference="rest" page-position="rest"/>
                        </fo:repeatable-page-master-alternatives>
                    </fo:page-sequence-master>
                 </fo:layout-master-set>
                    
                 <fo:page-sequence master-reference="global">
                     <fo:static-content flow-name="firstBefore">
                             <fo:table table-layout="fixed" width="160mm">
                                 <fo:table-column column-width="160mm" width="160mm"/>
                                 <fo:table-body>
                                     <fo:table-row>
                                         <fo:table-cell border-top="0.1mm solid black">
                                             <fo:block xsl:use-attribute-sets="title">Moralische Wochenschriften</fo:block>
                                             <fo:block xsl:use-attribute-sets="subtitle">Institut für Romanistik, Karl-Franzens-Universität Graz</fo:block>
                                         </fo:table-cell>
                                     </fo:table-row>
                                     <fo:table-row>
                                         <fo:table-cell border-top="0.1mm solid black">
                                             <fo:block xsl:use-attribute-sets="perma">
                                                 <xsl:text>Permalink: https://gams.uni-graz.at/</xsl:text>
                                                 <xsl:choose>
                                                     <xsl:when test="contains(//t:idno, 'info:fedora')">
                                                         <xsl:value-of select="substring-after(//t:idno, '/')" />
                                                     </xsl:when>
                                                     <xsl:otherwise>
                                                         <xsl:value-of select="//t:idno" />
                                                     </xsl:otherwise>
                                                 </xsl:choose>
                                             </fo:block>
                                         </fo:table-cell>
                                     </fo:table-row>
                                 </fo:table-body>
                             </fo:table>
                             
                             
                     </fo:static-content>
                     
                     
                     <fo:static-content flow-name="firstAfter">
                         <fo:block text-align="center" xsl:use-attribute-sets="pagenumber">&#x2014;<fo:page-number />&#x2014;</fo:block><!-- format="I" geht nicht -->
                     </fo:static-content>
                     
                     <fo:static-content flow-name="restAfter">
                         <fo:block text-align="center" xsl:use-attribute-sets="pagenumber">&#x2014;<fo:page-number />&#x2014;</fo:block>
                     </fo:static-content>
                     
                     <fo:static-content flow-name="xsl-footnote-separator">
                         <fo:block text-align="justify" space-before="1mm" space-after="1mm">
                             <fo:leader leader-length="30mm" rule-thickness="0.25pt" leader-pattern="rule" />
                         </fo:block>
                     </fo:static-content>
                     
                     <fo:flow flow-name="xsl-region-body">
                     
                     
                     
                     <xsl:if test="string-length(//t:bibl/t:title) > 1">

                           <fo:block xsl:use-attribute-sets="quotation"><fo:inline font-weight="bold"><i18n:text>Zitiervorschlag</i18n:text>:</fo:inline>
                                <xsl:text> </xsl:text><xsl:value-of select="//t:titleStmt/t:author"/> (<i18n:text>Hrsg.</i18n:text>): "<xsl:value-of
                                    select="//t:titleStmt/t:title"/>", <i18n:text>in</i18n:text>:
                                        <fo:inline font-style="italic"><xsl:value-of select="//t:sourceDesc/t:bibl/t:title"
                                    /></fo:inline><xsl:text>, Vol.</xsl:text>
                                    <xsl:choose>
                                    	<xsl:when test="//t:sourceDesc/t:bibl/t:biblScope[@unit = 'volume']">
                                    		<xsl:value-of
                                    select="//t:sourceDesc/t:bibl/t:biblScope[@unit = 'volume']"
                                    /><xsl:text>\</xsl:text><xsl:value-of
                                    select="//t:sourceDesc/t:bibl/t:biblScope[@unit = 'issue']"/>
                                    	</xsl:when>
                                    	<xsl:otherwise>
                                    		<xsl:value-of
                                    select="//t:sourceDesc/t:bibl/t:biblScope[@type = 'vol']"
                                    /><xsl:text>\</xsl:text><xsl:value-of
                                    select="//t:sourceDesc/t:bibl/t:biblScope[@type = 'issue']"/>	
                                    	</xsl:otherwise>
                                    </xsl:choose>
                                    
                                <xsl:text> (</xsl:text><xsl:value-of
                                    select="//t:sourceDesc/t:bibl/t:date"/>)<xsl:if
                                    test="//t:text//t:body//t:pb">, <i18n:text>S.</i18n:text><xsl:text> </xsl:text>
                                    <xsl:choose>
                                     <xsl:when test="//t:TEI/t:facsimile">
                                      <xsl:value-of select="$vLowest"/>-<xsl:value-of select="$vHighest"/>
                                     </xsl:when>
                                     <xsl:otherwise>
                                      <xsl:value-of select="$vLowest -1"/>-<xsl:value-of select="$vHighest"/>
                                      </xsl:otherwise>
                                      </xsl:choose>
                                </xsl:if>, <i18n:text>ediert in</i18n:text>:
                                
                                <xsl:choose>
                                	<xsl:when test="//t:respStmt[1]/t:resp='Herausgeber'">
                                		<xsl:for-each select="//t:respStmt[t:resp='Herausgeber']/t:name">
                                			<xsl:value-of select="concat(substring-after(., ' '), ', ', substring-before(., ' '))" />
                                			<xsl:if test="not(position()=last())">
                                				<xsl:text> / </xsl:text>
                                			</xsl:if>
                                		</xsl:for-each>
                                	</xsl:when>
                                	<xsl:otherwise>
                                	
                                <xsl:text>Ertler, Klaus-Dieter</xsl:text>
                                
                                    <xsl:if test="//t:language[@ident = 'es']"
                                    ><xsl:text> / Hobisch, Elisabeth</xsl:text></xsl:if>
                                <xsl:if test="//t:langUsage/t:language[@ident = 'fr']"> / Fischer-Pernkopf,
                                    Michaela</xsl:if>
                                <xsl:if test="//t:langUsage/t:language[@ident = 'it']">
                                   <xsl:choose>
                                        <xsl:when test="//t:respStmt/t:name[contains(.,'Kirsten Dickhaut')]"
                                            ><xsl:text> / Dickhaut, Kirsten / Fuchs, Alexandra</xsl:text></xsl:when>
                                        <xsl:when
                                            test="//t:respStmt/t:name[contains(., 'Angela Fabris')]"
                                            ><xsl:text> / Fabris, Angela / Fuchs, Alexandra</xsl:text></xsl:when>
                                        <xsl:otherwise>
                                        	<xsl:text> / Fuchs, Alexandra</xsl:text>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </xsl:if>
                                <xsl:if test="//t:langUsage/t:language[@ident = 'en']"> / Fuchs,
                                        Alexandra</xsl:if>
                                        
                                <xsl:if test="//t:sourceDesc//t:bibl[@xml:id = 'ZUS']"> / Fuchs, Alexandra</xsl:if>
								<xsl:if test="//t:sourceDesc//t:bibl[@xml:id = 'MZUS']"> / Fuchs,  Alexandra</xsl:if>
                                    
								<xsl:if test="//t:sourceDesc//t:bibl[@xml:id = 'LSP']"> / Doms, Misia Sophia / Hahne, Nina</xsl:if>
								<xsl:if test="//t:sourceDesc//t:bibl[@xml:id = 'BUER']"> / Doms, Misia Sophia / Hahne, Nina</xsl:if>
                                </xsl:otherwise>
                                </xsl:choose>
                                         
                                 (<i18n:text>Hrsg.</i18n:text>): <i18n:text>Spectators</i18n:text>. <i18n:text>Digitale Edition</i18n:text>, Graz 2011-2019,

<!--

    Saxon unterstützt leider keine Java Extension, also entweder umstellen auf XSLT 2.0 oder damit leben

       <xsl:value-of select="java:format(java:java.text.SimpleDateFormat.new('yyyy'), java:java.util.Date.new())"/>. <xsl:choose>
                                    <xsl:when test="string-length($handle) = 0"
                                            >https://gams.uni-graz.at/<xsl:value-of select="$idno"/>
                                            [<i18n:text>aufgerufen am</i18n:text>: <xsl:value-of select="java:format(java:java.text.SimpleDateFormat.new('dd.MM.yyyy'), java:java.util.Date.new())"/>]. </xsl:when>
                                    <xsl:otherwise>
-->
                                            hdl.handle.net/<xsl:value-of
                                            select="substring-after($handle, 'hdl:')"/>
                                          <!--  
                                          [<i18n:text>aufgerufen am</i18n:text>: 
                                            
                                            <xsl:value-of select="java:format(java:java.text.SimpleDateFormat.new('dd.MM.yyyy'), java:java.util.Date.new())"/>
                                            ].
                                    </xsl:otherwise>                                     

                                </xsl:choose>
-->
                            </fo:block>
                        </xsl:if>
                        
                      
                        
                        
                        
                     
                         <fo:block><xsl:apply-templates select="t:text/t:group/t:text[@ana='layout']/t:body" /></fo:block>
                     </fo:flow>
                 </fo:page-sequence>   
                        </fo:root>
        </xsl:template>
    
    <xsl:template match="t:text[@ana='layout']/t:body">
        <xsl:apply-templates />
    </xsl:template>
    
    <xsl:template match="t:div1">
        <xsl:apply-templates />
    </xsl:template>
    
    <xsl:template match="t:head">
        <fo:block xsl:use-attribute-sets="U1">
            <xsl:apply-templates />
        </fo:block>
    </xsl:template>
    
    <xsl:template match="t:div2/t:head">
        <fo:block xsl:use-attribute-sets="U2">
            <xsl:apply-templates />
        </fo:block>
    </xsl:template>
    
    <xsl:template match="t:div3/t:head">
        <fo:block xsl:use-attribute-sets="U3">
            <xsl:apply-templates/>
        </fo:block>
    </xsl:template>
    
    <xsl:template match="t:lb">
        <fo:block></fo:block>
    </xsl:template>
    
   <!--  <xsl:template match="t:p[@rend='AU']">
        <fo:block xsl:use-attribute-sets="AU">
            <xsl:apply-templates />
        </fo:block>
    </xsl:template>
    -->
    <xsl:template match="t:p[@rend='MO']">
        <fo:block xsl:use-attribute-sets="MO">
            <xsl:apply-templates />
        </fo:block>
    </xsl:template>
     
        <xsl:template match="t:p[@rend='QU']">
        <fo:block xsl:use-attribute-sets="QU">
            <xsl:apply-templates />
        </fo:block>
    </xsl:template>
    
    <xsl:template match="t:p[@rend='UM']">
        <fo:block xsl:use-attribute-sets="UM">
            <xsl:apply-templates />
        </fo:block>
    </xsl:template>
    
    <!-- <xsl:template match="t:p[@rend='EU']">
        <fo:block xsl:use-attribute-sets="EU">
            <xsl:apply-templates />
        </fo:block>
    </xsl:template>
    -->
    <xsl:template match="t:p[@rend='SO']">
        <fo:block xsl:use-attribute-sets="SO">
            <xsl:apply-templates />
        </fo:block>
    </xsl:template>
    
    <xsl:template match="t:p[@rend='date']">
        <fo:block xsl:use-attribute-sets="DT">
            <xsl:value-of select="."/>
        </fo:block>
    </xsl:template>
    
    
    <xsl:template match="t:p">
        <fo:block xsl:use-attribute-sets="ST">
        
        <!-- FIXME: hier muss die Abfrage gemacht werden, kein fixer Wert beim Attributset -->
           
            <!--<xsl:if test="not(following-sibling::t:p[1][@rend='EU'])">
                <xsl:attribute name="xsl:use-attribute-sets">
                    <xsl:text>ST</xsl:text>
                </xsl:attribute>
            </xsl:if>
            <xsl:if test="following-sibling::t:p[1][@rend='EU']">
                <xsl:attribute name="xsl:use-attribute-sets">
                    <xsl:text>ST last</xsl:text>
                </xsl:attribute>
            </xsl:if>-->
            <xsl:apply-templates />
        </fo:block>
    </xsl:template>
   
    <xsl:template match="t:hi[@rend='italic']">
        <fo:inline xsl:use-attribute-sets="italic">
            <xsl:apply-templates />
        </fo:inline>
    </xsl:template>
    
    <xsl:template match="t:hi[@rend='smallcaps']">
        <fo:inline xsl:use-attribute-sets="smallcaps">
            <xsl:apply-templates />
        </fo:inline>
    </xsl:template>
    
    <xsl:template match="t:hi[@rend='superscript']">
        <fo:inline xsl:use-attribute-sets="superscript">
            <xsl:apply-templates />
        </fo:inline>
    </xsl:template>
    

    <xsl:template match="text()">
       
        <xsl:variable name="bindestrich">
            <xsl:value-of select="substring(., string-length(.),  1)"/>
        </xsl:variable>
        <xsl:choose>
            <xsl:when test="$bindestrich='-'">
                <xsl:value-of select="substring(., 1, string-length(.) -1)"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="."/>
            </xsl:otherwise>
        </xsl:choose>
        
    </xsl:template>
    
   <xsl:template match="t:p[@rend='BU']">
        <fo:block xsl:use-attribute-sets="BU">
            <xsl:apply-templates />
        </fo:block>
    </xsl:template>
    
    <xsl:template match="t:p[@rend='BA']">
        <fo:block xsl:use-attribute-sets="BA">
            <xsl:apply-templates />
        </fo:block>
    </xsl:template>
    
    <xsl:template match="t:p[@rend='CI']">
        <fo:block xsl:use-attribute-sets="CI">
            <xsl:apply-templates />
        </fo:block>
    </xsl:template>
    
    <xsl:template match="t:milestone">
        <xsl:if test="$mode='analyse'">
    
        <xsl:choose>
            <xsl:when test="@rend='closer'">
                <xsl:variable name="setname" select="@unit" />
                <xsl:variable name="set" select="document('/mws/3mws-fo.xsl')/*/xsl:attribute-set[@name = $setname]" />
                 
                <fo:inline xsl:use-attribute-sets="milestone">
                     
                 <xsl:for-each select="$set/xsl:attribute">
                    <xsl:attribute name="{@name}">
                       <xsl:value-of select="." />
                    </xsl:attribute>
                 </xsl:for-each>
                     
                 <xsl:text>&#x00AB;&#x00A0;</xsl:text>
                 <xsl:call-template name="unit" />
                      
                </fo:inline>
            </xsl:when>
            <xsl:otherwise>
            	<xsl:variable name="setname1" select="@unit" />
                <xsl:variable name="set1" select="document('/mws/3mws-fo.xsl')/*/xsl:attribute-set[@name = $setname1]" />
                
            <fo:inline xsl:use-attribute-sets="milestone">
                     
                 <xsl:for-each select="$set1/xsl:attribute">
                    <xsl:attribute name="{@name}">
                       <xsl:value-of select="." />
                    </xsl:attribute>
                 </xsl:for-each>
                     
                 
                <xsl:call-template name="unit" />
                <xsl:text>&#x00A0;&#x00BB;</xsl:text>
                </fo:inline>
                
            </xsl:otherwise>
        </xsl:choose>
        </xsl:if>
        <xsl:apply-templates />
        
    </xsl:template>
    
    <xsl:template name="unit">
        <xsl:if test="@unit='E1'">
            <i18n:text>Ebene&#x00A0;1</i18n:text>
        </xsl:if>
        <xsl:if test="@unit='E2'">
            <i18n:text>Ebene&#x00A0;2</i18n:text>
        </xsl:if>
        <xsl:if test="@unit='E3'">
            <i18n:text>Ebene&#x00A0;3</i18n:text>
        </xsl:if>
        <xsl:if test="@unit='E4'">
            <i18n:text>Ebene&#x00A0;4</i18n:text>
        </xsl:if>
        <xsl:if test="@unit='E5'">
            <i18n:text>Ebene&#x00A0;5</i18n:text>
        </xsl:if>
        <xsl:if test="@unit='E6'">
            <i18n:text>Ebene&#x00A0;6</i18n:text>
        </xsl:if>
        <xsl:if test="@unit='AL'">
            <i18n:text>Allegorie</i18n:text>
        </xsl:if>
        <xsl:if test="@unit='AE'">
            <i18n:text>Allgemeine&#x00A0;Erzählung</i18n:text>
        </xsl:if>
        <xsl:if test="@unit='D'">
            <i18n:text>Dialog</i18n:text>
        </xsl:if>
        <xsl:if test="@unit='EX'">
            <i18n:text>Exemplum</i18n:text>
        </xsl:if>
        <xsl:if test="@unit='F'">
            <i18n:text>Fabel</i18n:text>
        </xsl:if>
        <xsl:if test="@unit='FP'">
            <i18n:text>Fremdportrait</i18n:text>
        </xsl:if>
        <xsl:if test="@unit='LB'">
            <i18n:text>Leserbrief</i18n:text>
        </xsl:if>
        <xsl:if test="@unit='MT'">
            <i18n:text>Metatextualität</i18n:text>
        </xsl:if>
        <xsl:if test="@unit='S'">
            <i18n:text>Satire</i18n:text>
        </xsl:if>
        <xsl:if test="@unit='SP'">
            <i18n:text>Selbstportrait</i18n:text>
        </xsl:if>
        <xsl:if test="@unit='TR'">
            <i18n:text>Traum</i18n:text>
        </xsl:if>
        <xsl:if test="@unit='UT'">
            <i18n:text>Utopie</i18n:text>
        </xsl:if>
        <xsl:if test="@unit='ZM'">
            <i18n:text>Zitat/Motto</i18n:text>
        </xsl:if>
    </xsl:template>

    <xsl:template match="t:pb">
        <xsl:if test="$mode='analyse'">
        <xsl:variable name="bindestrich">
            <xsl:value-of
                select="substring(preceding-sibling::text()[1],string-length(preceding-sibling::text()[1]),1)"
            />
        </xsl:variable>
        
        
        <fo:inline xsl:use-attribute-sets="seiten">
            <xsl:choose>
                <xsl:when test="$bindestrich='-'">
                    <xsl:text>-</xsl:text>
                </xsl:when>
                <xsl:otherwise> </xsl:otherwise>
            </xsl:choose>
            <xsl:text>[</xsl:text>
            <xsl:value-of select="@n"/>
            <xsl:text>]</xsl:text>
        </fo:inline>
        </xsl:if>
    </xsl:template>
    
    <xsl:template match="t:lg">
        <fo:block xsl:use-attribute-sets="lg">
            <xsl:apply-templates />
        </fo:block>
    </xsl:template>
    
    <xsl:template match="t:l">
        <xsl:if test="@rend='GF'">
            <fo:block xsl:use-attribute-sets="GF" orphans="2" widows="2">
                <xsl:apply-templates />
            </fo:block>
        </xsl:if>
        <xsl:if test="@rend='G1'">
            <fo:block xsl:use-attribute-sets="G1" orphans="2" widows="2">
                <xsl:apply-templates />
            </fo:block>
        </xsl:if>
    </xsl:template>
    
    <xsl:template match="t:list">
    	
    	
    	
    	<xsl:for-each select="t:label">
    	
    	<xsl:choose>
    		<xsl:when test="string-length(.) &gt; 3">
    	<fo:list-block xsl:use-attribute-sets="list" provisional-distance-between-starts="60pt"
    provisional-label-separation="10pt"
    start-indent="from-parent(start-indent) + 5pt">
           
         	<fo:list-item>
              	<fo:list-item-label>  
                		<fo:block>
                		
                	<xsl:apply-templates />
                </fo:block>
                	</fo:list-item-label>
                	
            <fo:list-item-body start-indent="body-start()">
                <fo:block>
                    <xsl:apply-templates select="following-sibling::t:item[1]"/>
                </fo:block>
            </fo:list-item-body>
            
        </fo:list-item>
        
        </fo:list-block>	
    		
    		</xsl:when>
    		
    		<xsl:otherwise>
    	<fo:list-block xsl:use-attribute-sets="list">
           
         	<fo:list-item>
              	<fo:list-item-label>  
                		<fo:block>
                		
                	<xsl:apply-templates />
                </fo:block>
                	</fo:list-item-label>
                	
            <fo:list-item-body start-indent="body-start()">
                <fo:block>
                    <xsl:apply-templates select="following-sibling::t:item[1]"/>
                </fo:block>
            </fo:list-item-body>
            
        </fo:list-item>
        
        </fo:list-block>	
    		
    		</xsl:otherwise>
    	</xsl:choose>
    	
    		
    	</xsl:for-each>
    	
    		<!-- <fo:list-block xsl:use-attribute-sets="list">
           
        <xsl:for-each select="t:item">
         	<fo:list-item>
           
            
                
                <xsl:choose>
                	<xsl:when test="string-length(preceding-sibling::t:label[1]) &gt; 3">
            <fo:list-item-label width="50mm" end-indent="label-end()">
                		<fo:block>
                	xxx<xsl:value-of select="string-length(preceding-sibling::t:label[1])" />
                   <xsl:apply-templates select="preceding-sibling::t:label[1]" />
                </fo:block>
                	</fo:list-item-label>
                	</xsl:when>
                	
                	<xsl:otherwise>
                		<fo:list-item-label end-indent="label-end()">
                		<fo:block>
                		
                	yyy<xsl:value-of select="string-length(preceding-sibling::t:label[1])" />
                   <xsl:apply-templates select="preceding-sibling::t:label[1]" />
                </fo:block>
            </fo:list-item-label>    
                	</xsl:otherwise>
                </xsl:choose>
                
            
            <fo:list-item-body start-indent="body-start()">
                <fo:block>
                    <xsl:apply-templates />
                </fo:block>
            </fo:list-item-body>
            
        </fo:list-item>
        
        </xsl:for-each>
        </fo:list-block>
        
         -->
          </xsl:template>
    
    
   <xsl:template match="t:label">
    <xsl:apply-templates />
   </xsl:template>
    
    <xsl:template match="t:note">
       
           
                <fo:footnote>
                    <fo:inline font-size="6pt">
                        <xsl:number level="any" />
                    </fo:inline>
                    
                    <fo:footnote-body>
                        <fo:block text-indent="0" text-align="left">
                            <fo:inline font-size="6pt" baseline-shift="super">
                                <xsl:number level="any" />
                            </fo:inline>
                            <fo:inline padding-left="5pt">
                                <xsl:apply-templates />
                            </fo:inline>
                        </fo:block>
                    </fo:footnote-body>
                    
                  
                </fo:footnote>
            
           
    </xsl:template>
    
   
    
    
    </xsl:stylesheet>
    
    
