forked from oeuvres/teinte
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtei2html.xsl
165 lines (162 loc) · 6.23 KB
/
tei2html.xsl
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
<?xml version="1.0" encoding="UTF-8"?>
<!--
<h1>TEI » HTML (tei2html.xsl)</h1>
LGPL http://www.gnu.org/licenses/lgpl.html
© 2005 ajlsm.com (Cybertheses)
© 2007 [email protected]
© 2010 [email protected] & École nationale des chartes
© 2012 [email protected]
© 2013 [email protected] & LABEX OBVIL
© 2019 [email protected] & LABEX OBVIL & Optéos
XSLT 1.0 is compatible browser, PHP, Python, Java…
-->
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" xmlns:tei="http://www.tei-c.org/ns/1.0" exclude-result-prefixes="tei">
<xsl:include href="xsl/flow.xsl"/>
<xsl:include href="xsl/notes.xsl"/>
<xsl:include href="xsl/teiHeader.xsl"/>
<xsl:include href="xsl/toc.xsl"/>
<!-- Name of this xsl -->
<xsl:param name="this">tei2html.xsl</xsl:param>
<!-- used as a body class -->
<xsl:param name="folder"/>
<!-- -->
<xsl:output encoding="UTF-8" indent="yes" method="xml" omit-xml-declaration="yes"/>
<!-- Output teiHeader ? -->
<xsl:param name="teiheader" select="true()"/>
<!-- Racine -->
<xsl:template match="/*">
<xsl:apply-templates select="." mode="html"/>
</xsl:template>
<xsl:template match="/*" mode="html">
<xsl:variable name="bodyclass">
<xsl:value-of select="$corpusid"/>
<xsl:text> </xsl:text>
<xsl:value-of select="$folder"/>
</xsl:variable>
<xsl:choose>
<!-- Just a div element -->
<xsl:when test="$root= $article">
<article>
<xsl:call-template name="att-lang"/>
<xsl:if test="normalize-space($bodyclass)">
<xsl:attribute name="class">
<xsl:value-of select="normalize-space($bodyclass)"/>
</xsl:attribute>
</xsl:if>
<xsl:apply-templates/>
</article>
</xsl:when>
<!-- Complete doc -->
<xsl:otherwise>
<!-- browser will not like doctype -->
<xsl:if test="$xslbase != $theme">
<xsl:text disable-output-escaping="yes"><!DOCTYPE html></xsl:text>
<xsl:value-of select="$lf"/>
</xsl:if>
<html>
<xsl:call-template name="att-lang"/>
<head>
<meta charset="UTF-8"/>
<link rel="preconnect" href="https://fonts.googleapis.com"/>
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin="crossorigin"/>
<link href="https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,300;0,400;0,700;0,900;1,300;1,700&display=swap" rel="stylesheet"/>
<meta name="modified" content="{$date}"/>
<!-- déclaration classes css locale (permettre la surcharge si généralisation) -->
<!-- à travailler
<xsl:apply-templates select="/*/tei:teiHeader/tei:encodingDesc/tei:tagsDecl"/>
-->
<link rel="stylesheet" type="text/css" href="{$theme}teinte.css"/>
<link rel="stylesheet" type="text/css" href="{$theme}layout.css"/>
</head>
<body>
<xsl:if test="normalize-space($bodyclass)">
<xsl:attribute name="class">
<xsl:value-of select="normalize-space($bodyclass)"/>
</xsl:attribute>
</xsl:if>
<div class="container" id="viewport">
<div id="text" class="text">
<xsl:apply-templates/>
</div>
<aside id="sidebar">
<nav>
<header>
<a>
<xsl:attribute name="href">
<xsl:for-each select="/*/tei:text">
<xsl:call-template name="href"/>
</xsl:for-each>
</xsl:attribute>
<xsl:if test="$byline">
<xsl:copy-of select="$byline"/>
<xsl:text> </xsl:text>
</xsl:if>
<xsl:if test="$docdate != ''">
<span class="docDate">
<xsl:text> (</xsl:text>
<xsl:value-of select="$docdate"/>
<xsl:text>)</xsl:text>
</span>
</xsl:if>
<br/>
<xsl:copy-of select="$doctitle"/>
</a>
</header>
<xsl:call-template name="toc"/>
</nav>
</aside>
</div>
<xsl:if test="count(key('prettify', 1))">
<script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js">//</script>
</xsl:if>
<script type="text/javascript" charset="utf-8" src="{$theme}Tree.js">//</script>
</body>
</html>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Bloc de métadonnées -->
<xsl:template match="tei:teiHeader">
<!-- Parametrize ? -->
<xsl:choose>
<xsl:when test="not($teiheader)"/>
<xsl:when test="../tei:text/tei:front/tei:titlePage"/>
<xsl:otherwise>
<xsl:apply-templates select="tei:fileDesc"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="tei:text">
<xsl:param name="level" select="count(ancestor::tei:group)"/>
<article>
<xsl:attribute name="id">
<xsl:call-template name="id"/>
</xsl:attribute>
<xsl:call-template name="atts"/>
<xsl:apply-templates select="*">
<xsl:with-param name="level" select="$level +1"/>
</xsl:apply-templates>
<!-- groupes de textes, procéder les notes par textes -->
<xsl:if test="not(tei:group)">
<!-- No notes in teiHeader ? -->
<xsl:call-template name="footnotes"/>
</xsl:if>
</article>
</xsl:template>
<xsl:template match="*" priority="-1">
<xsl:choose>
<xsl:when test="namespace-uri(/*) = namespace-uri()">
<xsl:element name="{local-name()}">
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:transform>