root / tmp / org.txm.oriflamms.rcp / bin / 1-default-html.xsl @ 476
History | View | Annotate | Download (17.4 kB)
1 |
<?xml version="1.0"?> |
---|---|
2 |
<xsl:stylesheet xmlns:edate="http://exslt.org/dates-and-times" |
3 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
4 |
xmlns:tei="http://www.tei-c.org/ns/1.0" |
5 |
xmlns:txm="http://textometrie.org/1.0" |
6 |
xmlns:xs="http://www.w3.org/2001/XMLSchema" |
7 |
exclude-result-prefixes="#all" version="2.0"> |
8 |
|
9 |
<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="no" indent="no"/> |
10 |
|
11 |
<!-- <xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="no" indent="no" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/> --> |
12 |
|
13 |
|
14 |
<xsl:strip-space elements="*"/> |
15 |
|
16 |
<xsl:param name="pagination-element">pb</xsl:param> |
17 |
|
18 |
<xsl:variable name="word-element"> |
19 |
<xsl:choose> |
20 |
<xsl:when test="//tei:c//txm:form">c</xsl:when> |
21 |
<xsl:otherwise>w</xsl:otherwise> |
22 |
</xsl:choose> |
23 |
</xsl:variable> |
24 |
|
25 |
<xsl:variable name="page-number-adjust" as="xs:integer"> |
26 |
<xsl:choose> |
27 |
<xsl:when test="//tei:c//txm:form">1</xsl:when> |
28 |
<xsl:otherwise>2</xsl:otherwise> |
29 |
</xsl:choose> |
30 |
</xsl:variable> |
31 |
|
32 |
|
33 |
<xsl:variable name="inputtype"> |
34 |
<xsl:choose> |
35 |
<xsl:when test="//tei:w//txm:form">xmltxm</xsl:when> |
36 |
<xsl:otherwise>xmlw</xsl:otherwise> |
37 |
</xsl:choose> |
38 |
</xsl:variable> |
39 |
|
40 |
<xsl:variable name="filename"> |
41 |
<xsl:analyze-string select="document-uri(.)" regex="^(.*)/([^/]+)\.[^/]+$"> |
42 |
<xsl:matching-substring> |
43 |
<xsl:value-of select="regex-group(2)"/> |
44 |
</xsl:matching-substring> |
45 |
</xsl:analyze-string> |
46 |
</xsl:variable> |
47 |
|
48 |
<xsl:template match="/"> |
49 |
<html> |
50 |
<head> |
51 |
<title><xsl:choose> |
52 |
<xsl:when test="//tei:text/@id"><xsl:value-of select="//tei:text[1]/@id"/></xsl:when> |
53 |
<xsl:otherwise><xsl:value-of select="$filename"/></xsl:otherwise> |
54 |
</xsl:choose></title> |
55 |
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/> |
56 |
<link rel="stylesheet" media="all" type="text/css" href="css/bvhepistemon2014.css" /> |
57 |
<!-- <title> |
58 |
<xsl:if test="$author[not(contains(.,'anonym'))]"> |
59 |
<xsl:value-of select="$author"/><xsl:text> : </xsl:text> |
60 |
</xsl:if> |
61 |
<xsl:value-of select="$title-normal"/> |
62 |
</title> --> |
63 |
</head> |
64 |
<xsl:apply-templates select="descendant::tei:text"/> |
65 |
</html> |
66 |
</xsl:template> |
67 |
|
68 |
<xsl:template match="tei:text"> |
69 |
<body> |
70 |
<xsl:if test="$word-element='w'"> |
71 |
<a class="txm-page" title="1" next-word-id="w_0"/> |
72 |
<div class="metadata-page"> |
73 |
<h1><xsl:value-of select="@id"></xsl:value-of></h1> |
74 |
<br/> |
75 |
<table> |
76 |
<xsl:for-each select="@*"> |
77 |
<tr> |
78 |
<td><xsl:value-of select="name()"/></td> |
79 |
<td><xsl:value-of select="."/></td> |
80 |
</tr> |
81 |
</xsl:for-each> |
82 |
</table> |
83 |
</div> |
84 |
|
85 |
</xsl:if> |
86 |
<xsl:apply-templates/> |
87 |
</body> |
88 |
</xsl:template> |
89 |
|
90 |
<xsl:template match="*"> |
91 |
<xsl:choose> |
92 |
<xsl:when test="descendant::tei:p|descendant::tei:ab"> |
93 |
<div> |
94 |
<xsl:call-template name="addClass"/> |
95 |
<xsl:apply-templates/></div> |
96 |
<xsl:text>
</xsl:text> |
97 |
</xsl:when> |
98 |
<xsl:otherwise><span> |
99 |
<xsl:call-template name="addClass"/> |
100 |
<xsl:if test="self::tei:add[@del]"> |
101 |
<xsl:attribute name="title"><xsl:value-of select="@del"/></xsl:attribute> |
102 |
</xsl:if> |
103 |
<xsl:apply-templates/></span> |
104 |
<xsl:call-template name="spacing"/> |
105 |
</xsl:otherwise> |
106 |
</xsl:choose> |
107 |
</xsl:template> |
108 |
|
109 |
<xsl:template match="@*|processing-instruction()|comment()"> |
110 |
<!--<xsl:copy/>--> |
111 |
</xsl:template> |
112 |
|
113 |
<!-- <xsl:template match="comment()"> |
114 |
<xsl:copy/> |
115 |
</xsl:template> |
116 |
--> |
117 |
<xsl:template match="text()"> |
118 |
<xsl:value-of select="normalize-space(.)"/> |
119 |
</xsl:template> |
120 |
|
121 |
<xsl:template name="addClass"> |
122 |
<xsl:attribute name="class"> |
123 |
<xsl:value-of select="local-name(.)"/> |
124 |
<xsl:if test="@type"><xsl:value-of select="concat('-',@type)"/></xsl:if> |
125 |
<xsl:if test="@subtype"><xsl:value-of select="concat('-',@subtype)"/></xsl:if> |
126 |
<xsl:if test="@rend"><xsl:value-of select="concat('-',@rend)"/></xsl:if> |
127 |
</xsl:attribute> |
128 |
</xsl:template> |
129 |
|
130 |
<xsl:template match="tei:p|tei:ab|tei:lg"> |
131 |
<p> |
132 |
<xsl:call-template name="addClass"/> |
133 |
<xsl:apply-templates/> |
134 |
</p> |
135 |
<xsl:text>
</xsl:text> |
136 |
</xsl:template> |
137 |
|
138 |
<xsl:template match="tei:head"> |
139 |
<h2> |
140 |
<xsl:call-template name="addClass"/> |
141 |
<xsl:apply-templates/> |
142 |
</h2> |
143 |
</xsl:template> |
144 |
|
145 |
<xsl:template match="//tei:lb"> |
146 |
<xsl:variable name="lbcount"> |
147 |
<xsl:choose> |
148 |
<xsl:when test="ancestor::tei:ab"><xsl:number from="tei:ab" level="any"/></xsl:when> |
149 |
<xsl:when test="ancestor::tei:p"><xsl:number from="tei:p" level="any"/></xsl:when> |
150 |
<xsl:otherwise>999</xsl:otherwise> |
151 |
</xsl:choose> |
152 |
</xsl:variable> |
153 |
<xsl:if test="@rend='hyphen(-)'"><span class="hyphen">-</span></xsl:if> |
154 |
<xsl:if test="@rend='hyphen(=)'"><span class="hyphen">=</span></xsl:if> |
155 |
<xsl:if test="not($lbcount=1) or preceding-sibling::node()[matches(.,'\S')]"><br/><xsl:text>
</xsl:text></xsl:if> |
156 |
<!-- <xsl:if test="@n and not(@rend='prose')"> |
157 |
<xsl:choose> |
158 |
<xsl:when test="matches(@n,'^[0-9]*[05]$')"> |
159 |
<!-\-<a title="{@n}" class="verseline" style="position:relative"> </a>-\-> |
160 |
<span class="verseline"><span class="verselinenumber"><xsl:value-of select="@n"/></span></span> |
161 |
</xsl:when> |
162 |
<xsl:when test="matches(@n,'[^0-9]')"> |
163 |
<!-\-<a title="{@n}" class="verseline" style="position:relative"> </a>-\-> |
164 |
<span class="verseline"><span class="verselinenumber"><xsl:value-of select="@n"/></span></span> |
165 |
</xsl:when> |
166 |
<xsl:otherwise> |
167 |
</xsl:otherwise> |
168 |
</xsl:choose> |
169 |
</xsl:if>--> |
170 |
<xsl:if test="@n"><span class="verseline"><span class="verselinenumber"><xsl:value-of select="@n"/></span></span></xsl:if> |
171 |
</xsl:template> |
172 |
|
173 |
<!-- Page breaks --> |
174 |
<xsl:template match="//*[local-name()=$pagination-element]"> |
175 |
|
176 |
<xsl:variable name="next-word-position" as="xs:integer"> |
177 |
<xsl:choose> |
178 |
<xsl:when test="following::*[local-name()=$word-element]"> |
179 |
<xsl:value-of select="count(following::*[local-name()=$word-element][1]/preceding::*[local-name()=$word-element])"/> |
180 |
</xsl:when> |
181 |
<xsl:otherwise>0</xsl:otherwise> |
182 |
</xsl:choose> |
183 |
</xsl:variable> |
184 |
<xsl:variable name="next-pb-position" as="xs:integer"> |
185 |
<xsl:choose> |
186 |
<xsl:when test="following::*[local-name()=$pagination-element]"> |
187 |
<xsl:value-of select="count(following::*[local-name()=$pagination-element][1]/preceding::*[local-name()=$word-element])"/> |
188 |
</xsl:when> |
189 |
<xsl:otherwise>999999999</xsl:otherwise> |
190 |
</xsl:choose> |
191 |
</xsl:variable> |
192 |
<xsl:variable name="next-word-id"> |
193 |
<xsl:choose> |
194 |
<xsl:when test="$next-pb-position - $next-word-position = 999999999">w_0</xsl:when> |
195 |
<xsl:when test="$next-pb-position > $next-word-position"><xsl:value-of select="following::*[local-name()=$word-element][1]/@id"/></xsl:when> |
196 |
<xsl:otherwise>w_0</xsl:otherwise> |
197 |
</xsl:choose> |
198 |
</xsl:variable> |
199 |
|
200 |
|
201 |
<xsl:variable name="editionpagetype"> |
202 |
<xsl:choose> |
203 |
<xsl:when test="ancestor::tei:ab">editionpageverse</xsl:when> |
204 |
<xsl:otherwise>editionpage</xsl:otherwise> |
205 |
</xsl:choose> |
206 |
</xsl:variable> |
207 |
<xsl:variable name="pagenumber"> |
208 |
<xsl:choose> |
209 |
<xsl:when test="@n"><xsl:value-of select="@n"/></xsl:when> |
210 |
<xsl:when test="@facs"><xsl:value-of select="substring-before(@facs,'.')"/></xsl:when> |
211 |
<xsl:otherwise>[NN]</xsl:otherwise> |
212 |
</xsl:choose> |
213 |
</xsl:variable> |
214 |
|
215 |
<xsl:variable name="page_id"><xsl:value-of select="count(preceding::*[local-name()=$pagination-element])"/></xsl:variable> |
216 |
|
217 |
<xsl:if test="//tei:note[not(@place='inline') and not(matches(@type,'intern|auto'))][following::*[local-name()=$pagination-element][1][count(preceding::*[local-name()=$pagination-element]) = $page_id]]"> |
218 |
<xsl:text>
</xsl:text> |
219 |
<br/> |
220 |
<br/> |
221 |
<span style="display:block;border-top-style:solid;border-top-width:1px;border-top-color:gray;padding-top:5px"> |
222 |
<xsl:for-each select="//tei:note[not(@place='inline') and not(matches(@type,'intern|auto'))][following::*[local-name()=$pagination-element][1][count(preceding::*[local-name()=$pagination-element]) = $page_id]]"> |
223 |
<xsl:variable name="note_count"><xsl:value-of select="count(preceding::tei:note[not(@place='inline')]) + 1"/></xsl:variable> |
224 |
<!--<p><xsl:value-of select="$note_count"/>. <a href="#noteref_{$note_count}" name="note_{$note_count}">[<xsl:value-of select="preceding::tei:cb[1]/@xml:id"/>, l. <xsl:value-of select="preceding::tei:lb[1]/@n"/>]</a><xsl:text> </xsl:text> <xsl:value-of select="."/></p>--> |
225 |
<span class="note"> |
226 |
<span style="position:absolute;left:-30px"><a href="#noteref_{$note_count}" name="note_{$note_count}"><xsl:value-of select="$note_count"/></a>. </span> |
227 |
<xsl:apply-templates mode="#current"/> |
228 |
</span> |
229 |
</xsl:for-each></span><xsl:text>
</xsl:text> |
230 |
|
231 |
</xsl:if> |
232 |
|
233 |
<xsl:text>
</xsl:text> |
234 |
<br/><xsl:text>
</xsl:text> |
235 |
<a class="txm-page" title="{count(preceding::*[local-name()=$pagination-element]) + $page-number-adjust}" next-word-id="{$next-word-id}"/> |
236 |
<span class="{$editionpagetype}"> - <xsl:value-of select="$pagenumber"/> - </span><br/><xsl:text>
</xsl:text> |
237 |
</xsl:template> |
238 |
|
239 |
<!-- Notes --> |
240 |
<xsl:template match="tei:note[not(@place='inline') and not(matches(@type,'intern|auto'))]"> |
241 |
<!--<span style="color:violet"> [<b>Note :</b> <xsl:apply-templates/>] </span>--> |
242 |
<xsl:variable name="note_count"><xsl:value-of select="count(preceding::tei:note[not(@place='inline') and not(matches(@type,'intern|auto'))]) + 1"/></xsl:variable> |
243 |
<xsl:variable name="note_content"> |
244 |
<xsl:choose> |
245 |
<xsl:when test="descendant::txm:form"> |
246 |
<xsl:for-each select="descendant::txm:form"> |
247 |
<xsl:value-of select="."/> |
248 |
<xsl:if test="not(matches(following::txm:form[1],'^[.,\)]')) and not(matches(.,'^\S+[''’]$|^[‘\(]$'))"> |
249 |
<xsl:text> </xsl:text> |
250 |
</xsl:if> |
251 |
</xsl:for-each> |
252 |
</xsl:when> |
253 |
<xsl:otherwise><xsl:value-of select="normalize-space(.)"/></xsl:otherwise> |
254 |
</xsl:choose> |
255 |
</xsl:variable> |
256 |
<a title="{$note_content}" style="font-size:75%;position:relative;top:-5px" href="#note_{$note_count}" name="noteref_{$note_count}">[<xsl:value-of select="$note_count"/>]</a> |
257 |
<xsl:call-template name="spacing"/> |
258 |
</xsl:template> |
259 |
|
260 |
<xsl:template match="tei:note[@place='inline']"> |
261 |
<span class="noteinline"> |
262 |
<xsl:apply-templates/> |
263 |
</span> |
264 |
</xsl:template> |
265 |
|
266 |
<xsl:template match="//tei:w"><span class="w"> |
267 |
<xsl:choose> |
268 |
<xsl:when test="descendant::tei:c//txm:form"> |
269 |
<xsl:apply-templates select="descendant::tei:c"/> |
270 |
</xsl:when> |
271 |
<xsl:otherwise> |
272 |
<xsl:if test="@id"> |
273 |
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute> |
274 |
</xsl:if> |
275 |
<xsl:attribute name="title"> |
276 |
<xsl:if test="@id"> |
277 |
<xsl:value-of select="@id"></xsl:value-of> |
278 |
</xsl:if> |
279 |
<xsl:if test="ancestor::tei:corr"> |
280 |
<xsl:value-of select="concat(' sic : ',@sic)"/> |
281 |
</xsl:if> |
282 |
<xsl:if test="ancestor::tei:reg"> |
283 |
<xsl:value-of select="concat(' orig : ',@orig)"/> |
284 |
</xsl:if> |
285 |
<xsl:choose> |
286 |
<xsl:when test="descendant::txm:ana"> |
287 |
<xsl:for-each select="descendant::txm:ana"> |
288 |
<xsl:value-of select="concat(' ',substring-after(@type,'#'),' : ',.)"/> |
289 |
</xsl:for-each> |
290 |
</xsl:when> |
291 |
<xsl:otherwise> |
292 |
<xsl:for-each select="@*[not(local-name()='id')]"> |
293 |
<xsl:value-of select="concat(' ',name(.),' : ',.)"/> |
294 |
</xsl:for-each> |
295 |
</xsl:otherwise> |
296 |
</xsl:choose> |
297 |
<xsl:if test="@*[matches(name(.),'pos$')]"> |
298 |
</xsl:if> |
299 |
</xsl:attribute> |
300 |
<xsl:choose> |
301 |
<xsl:when test="descendant::txm:form"> |
302 |
<xsl:apply-templates select="txm:form"/> |
303 |
</xsl:when> |
304 |
<xsl:otherwise><xsl:apply-templates/></xsl:otherwise> |
305 |
</xsl:choose> |
306 |
</xsl:otherwise> |
307 |
</xsl:choose> |
308 |
</span><xsl:call-template name="spacing"/></xsl:template> |
309 |
|
310 |
<!-- <xsl:template match="//txm:form"> |
311 |
<xsl:apply-templates/> |
312 |
</xsl:template> |
313 |
--> |
314 |
|
315 |
<xsl:template match="//tei:c[descendant::txm:form]"> |
316 |
<span class="c"> |
317 |
<xsl:if test="@id"> |
318 |
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute> |
319 |
</xsl:if> |
320 |
<xsl:attribute name="title"> |
321 |
<xsl:if test="@id"> |
322 |
<xsl:value-of select="@id"></xsl:value-of> |
323 |
</xsl:if> |
324 |
<xsl:choose> |
325 |
<xsl:when test="descendant::txm:ana"> |
326 |
<xsl:for-each select="descendant::txm:ana"> |
327 |
<xsl:if test="matches(@type,'expan|characters|letters-all|letters-alignable|abbr-n')"> |
328 |
<xsl:value-of select="concat(' ',substring-after(@type,'#'),' : ',.)"/> |
329 |
</xsl:if> |
330 |
</xsl:for-each> |
331 |
</xsl:when> |
332 |
<xsl:otherwise> |
333 |
<xsl:for-each select="@*[not(local-name()='id')]"> |
334 |
<xsl:value-of select="concat(' ',name(.),' : ',.)"/> |
335 |
</xsl:for-each> |
336 |
</xsl:otherwise> |
337 |
</xsl:choose> |
338 |
<xsl:if test="@*[matches(name(.),'pos$')]"> |
339 |
</xsl:if> |
340 |
</xsl:attribute> |
341 |
<xsl:choose> |
342 |
<xsl:when test="descendant::txm:form"> |
343 |
<xsl:apply-templates select="txm:form"/> |
344 |
</xsl:when> |
345 |
<xsl:otherwise><xsl:apply-templates/></xsl:otherwise> |
346 |
</xsl:choose> |
347 |
|
348 |
</span> |
349 |
</xsl:template> |
350 |
|
351 |
<xsl:template name="spacing"> |
352 |
<xsl:choose> |
353 |
<xsl:when test="$inputtype='xmltxm'"> |
354 |
<xsl:call-template name="spacing-xmltxm"/> |
355 |
</xsl:when> |
356 |
<xsl:otherwise> |
357 |
<xsl:call-template name="spacing-xmlw"/> |
358 |
</xsl:otherwise> |
359 |
</xsl:choose> |
360 |
</xsl:template> |
361 |
|
362 |
<xsl:template name="spacing-xmlw"> |
363 |
<xsl:choose> |
364 |
<xsl:when test="ancestor::tei:w"/> |
365 |
<xsl:when test="following::tei:w[1][matches(.,'^\s*[.,)\]]+\s*$')]"/> |
366 |
<xsl:when test="matches(.,'^\s*[(\[‘]+$|\w(''|’)\s*$')"></xsl:when> |
367 |
<xsl:when test="position()=last() and (ancestor::tei:choice or ancestor::tei:supplied[not(@rend='multi_s')])"></xsl:when> |
368 |
<xsl:when test="following-sibling::*[1][self::tei:note]"></xsl:when> |
369 |
<xsl:when test="following::tei:w[1][matches(.,'^\s*[:;!?]+\s*$')]"> |
370 |
<xsl:text> </xsl:text> |
371 |
</xsl:when> |
372 |
<xsl:otherwise> |
373 |
<xsl:text> </xsl:text> |
374 |
</xsl:otherwise> |
375 |
</xsl:choose> |
376 |
</xsl:template> |
377 |
|
378 |
<xsl:template name="spacing-xmltxm"> |
379 |
<xsl:choose> |
380 |
<xsl:when test="ancestor::tei:w"/> |
381 |
<xsl:when test="following::tei:w[1][matches(descendant::txm:form[1],'^[.,)\]]+$')]"/> |
382 |
<xsl:when test="matches(descendant::txm:form[1],'^[(\[‘]+$|\w(''|’)$')"></xsl:when> |
383 |
<xsl:when test="position()=last() and (ancestor::tei:choice or ancestor::tei:supplied[not(@rend='multi_s')])"></xsl:when> |
384 |
<xsl:when test="following-sibling::*[1][self::tei:note]"></xsl:when> |
385 |
<xsl:when test="following::tei:w[1][matches(descendant::txm:form[1],'^[:;!?]+$')]"> |
386 |
<xsl:text> </xsl:text> |
387 |
</xsl:when> |
388 |
<xsl:otherwise> |
389 |
<xsl:text> </xsl:text> |
390 |
</xsl:otherwise> |
391 |
</xsl:choose> |
392 |
</xsl:template> |
393 |
|
394 |
|
395 |
</xsl:stylesheet> |