File size: 5,460 Bytes
9a1f9ba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0" 
    xmlns:eg="http://www.tei-c.org/ns/Examples"
    xmlns:tei="http://www.tei-c.org/ns/1.0" 
    xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
    xmlns:exsl="http://exslt.org/common"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt"
    xmlns:fn="http://www.w3.org/2005/xpath-functions"
    extension-element-prefixes="exsl msxsl"
    xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:html="http://www.w3.org/1999/xhtml" 
    exclude-result-prefixes="xsl tei xd eg fn #default">
    
    <!-- import teibp.xsl, which allows templates, 
         variables, and parameters from teibp.xsl 
         to be overridden here. -->
    <xsl:import href="https://repository.ortolang.fr/api/content/tei-boilerplate-custom/latest/content/teibp.xsl"/> 


    <!-- <xsl:template match="tei:pb"> -->
      <!-- we have to solve the pointer ; either it already is an http link,
	   or it is an xml pointer towards the facsilime part of the tei file -->
      <!-- well, in practice, we know it is a pointer towards the facsimile ! -->
      <!-- moreover, we should have all images not refered to by a pb diosplayed first... -->
    <!-- </xsl:template> -->

    

   
    <xsl:template match="tei:pb[@facs]">
		<xsl:param name="pn">
			<xsl:number count="//tei:pb" level="any"/>    
		</xsl:param>
		<xsl:variable name="theFacs" select="@facs"/>
		<xsl:variable name="theImage" select="//tei:surface[concat('#', @xml:id) = $theFacs]/tei:graphic/@url"/>

		
		<xsl:choose>
		<xsl:when test="$displayPageBreaks = true()">
					<span class="-teibp-pb">
						<xsl:call-template name="addID"/>
						<xsl:call-template name="pb-handler">
							<xsl:with-param name="n" select="@n"/>
							<xsl:with-param name="facs" select="$theImage"/>
							<xsl:with-param name="id">
								<xsl:choose>
								<xsl:when test="@xml:id">
									<xsl:value-of select="@xml:id"/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="generate-id()"/>
								</xsl:otherwise>
								</xsl:choose>
							</xsl:with-param>
						</xsl:call-template>
					</span>
		</xsl:when>
			<xsl:otherwise>
				<xsl:copy>
					<xsl:apply-templates select="@*|node()"/>
				</xsl:copy>
			</xsl:otherwise>
		</xsl:choose>
    </xsl:template>

    <xsl:template match="tei:facsimile">
      <xsl:text>Pièces annexes (sceaux, verso, etc...)</xsl:text>
      <xsl:apply-templates/>
      <br/>
    </xsl:template>

    <!-- <xsl:template match="tei:text">
      <xsl:text>Le texte :</xsl:text>
      <xsl:apply-templates/>
    </xsl:template> -->
    
    <xsl:template match="tei:surface">
      <xsl:variable name="myId" select="@xml:id"/>
      <xsl:variable name="theImage" select="tei:graphic/@url"/>
      <xsl:if test="not(//tei:pb[@facs=concat('#', $myId)])">
	<span class="-teibp-pb">
	  <xsl:call-template name="addID"/>
	  <xsl:call-template name="pb-handler">
	    <xsl:with-param name="n" select="0"/>
	    <xsl:with-param name="facs" select="$theImage"/>
	    <xsl:with-param name="id">
	      <xsl:choose>
		<xsl:when test="@xml:id">
		  <xsl:value-of select="@xml:id"/>
		</xsl:when>
		<xsl:otherwise>
		  <xsl:value-of select="generate-id()"/>
		</xsl:otherwise>
	      </xsl:choose>
	    </xsl:with-param>
	  </xsl:call-template>
	</span>
      </xsl:if>
    </xsl:template>


    <!--<xsl:template match="tei:item">
      <span id="translate(tei:persname/text(), ' ', '_')">
      <xsl:copy>
	<xsl:apply-templates select="@* | node()"/>
      </xsl:copy></span>
    </xsl:template> -->

    <xsl:template match="tei:item">
      <span id="{normalize-space(node()[1])}">
	<xsl:apply-templates/>
      </span>
    </xsl:template>

    
    <xsl:template match="tei:table">
      <table>
	<xsl:apply-templates/>
      </table>
    </xsl:template>
    
    <xsl:template match="tei:row">
      <tr>
      <xsl:apply-templates select="tei:cell[1]"/>
      <xsl:text> </xsl:text>
      <em><xsl:apply-templates select="tei:cell[2]"/></em>
      <xsl:text> </xsl:text>
      <xsl:apply-templates select="tei:cell[3]"/>
      </tr>
    </xsl:template>
    
    <xsl:template match="tei:cell">
      <td>
      <xsl:variable name="contexte">25</xsl:variable>
      <xsl:choose>
	<xsl:when test="preceding-sibling::tei:cell and following-sibling::tei:cell">
	  <xsl:attribute name="style">text-align:center;</xsl:attribute>
	  <xsl:apply-templates/>
	</xsl:when>
	<xsl:when test="not(following-sibling::tei:cell)">
	  <xsl:value-of select="substring(., 1, $contexte)"/>
	</xsl:when>
	<xsl:when test="not(preceding-sibling::tei:cell)">
	  <xsl:variable name="bi">
	    <xsl:value-of select="string-length(.)-$contexte"/>
	  </xsl:variable>
	  <xsl:variable name="max">
	    <xsl:choose>
	      <xsl:when test="$bi &lt; 1">
		<xsl:text>1</xsl:text>
	      </xsl:when>
	      <xsl:otherwise><xsl:value-of select="$bi"/></xsl:otherwise>
	    </xsl:choose>
	  </xsl:variable>
	  <xsl:value-of select="substring(., $max, string-length(.))"/>
	</xsl:when>

	<xsl:otherwise>
	  <xsl:attribute name="style">text-align:center;</xsl:attribute>
	  <xsl:apply-templates/>
	</xsl:otherwise>
      </xsl:choose>
      </td>
    </xsl:template>

    <xsl:template match="tei:persName">
      <xsl:value-of select="."/>
    </xsl:template>

    <xsl:template match="tei:ref">
      <a href="{@target}"><xsl:apply-templates/></a>
    </xsl:template>
</xsl:stylesheet>