Repository navigation
Expand file tree
/
Copy pathcore.xsl
More file actions
253 lines (239 loc) · 10.4 KB
/
Copy pathcore.xsl
File metadata and controls
253 lines (239 loc) · 10.4 KB
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
<xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:t="http://www.tei-c.org/ns/1.0" xmlns:x="http://www.w3.org/1999/xhtml" xmlns:saxon="http://saxon.sf.net/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:local="http://syriaca.org/ns" exclude-result-prefixes="xs t x saxon local" version="2.0">
<!-- =================================================================== -->
<!-- Core TEI to HTML transformations -->
<!-- =================================================================== -->
<!-- A -->
<xsl:template match="t:abbr">
<abbr>
<xsl:sequence select="local:attributes(.)"/>
<xsl:call-template name="rend"/>
</abbr>
</xsl:template>
<!-- C -->
<xsl:template match="t:cell">
<td>
<xsl:call-template name="rend"/>
</td>
</xsl:template>
<!-- G -->
<xsl:template match="t:graphic">
<img src="{string(@url)}"/>
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="child::*"/>
</xsl:template>
<!-- H -->
<xsl:template match="t:head">
<xsl:choose>
<xsl:when test="parent::t:div1">
<h2>
<xsl:sequence select="local:attributes(.)"/>
<xsl:call-template name="rend"/>
</h2>
</xsl:when>
<xsl:when test="parent::t:div2">
<h3>
<xsl:sequence select="local:attributes(.)"/>
<xsl:call-template name="rend"/>
</h3>
</xsl:when>
<xsl:otherwise>
<span class="tei-{name(parent::*[1])} tei-head">
<xsl:sequence select="local:attributes(.)"/>
<xsl:call-template name="rend"/>
</span>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- L -->
<xsl:template match="t:l">
<xsl:element name="{if (ancestor::t:hi) then 'span' else 'div'}">
<xsl:attribute name="class">tei-l</xsl:attribute>
<xsl:sequence select="local:attributes(.)"/>
<xsl:call-template name="rend"/>
</xsl:element>
</xsl:template>
<xsl:template match="t:lb">
<br/>
</xsl:template>
<xsl:template match="t:lg">
<div class="tei-{local-name(.)}">
<xsl:sequence select="local:attributes(.)"/>
<xsl:call-template name="rend"/>
</div>
</xsl:template>
<!-- Handles t:link elements for deperciated notes, pulls value from matching element, output element and footnotes -->
<xsl:template match="t:link">
<xsl:variable name="elementID" select="substring-after(substring-before(@target,' '),'#')"/>
<xsl:for-each select="/descendant-or-self::*[@xml:id=$elementID]">
<xsl:apply-templates select="."/>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:template>
<xsl:template match="t:list">
<xsl:if test="t:head">
<xsl:apply-templates select="t:head"/>
</xsl:if>
<xsl:choose>
<xsl:when test="@type='catalogue'">
<p>
<dl>
<xsl:for-each select="*[not(self::t:head)]">
<p/>
<xsl:apply-templates select="."/>
</xsl:for-each>
</dl>
</p>
</xsl:when>
<xsl:when test="@type='gloss' and contains(@rend,'multicol')">
<xsl:variable name="nitems">
<xsl:value-of select="count(t:item) div 2"/>
</xsl:variable>
<p>
<table>
<tr>
<td style="vertical-align:top;">
<dl>
<xsl:apply-templates select="t:item[position()<=$nitems ]"/>
</dl>
</td>
<td style="vertical-align:top;">
<dl>
<xsl:apply-templates select="t:item[position() >$nitems]"/>
</dl>
</td>
</tr>
</table>
</p>
</xsl:when>
<xsl:when test="@type='inline' or @type='runin'">
<p>
<xsl:apply-templates select="*[not(self::t:head or self::t:trailer)]" mode="inline"/>
</p>
</xsl:when>
<xsl:when test="@type='bibl'">
<xsl:apply-templates select="*[not(self::t:head or self::t:trailer)]" mode="bibl"/>
</xsl:when>
<xsl:otherwise>
<xsl:element name="ul">
<xsl:if test="starts-with(@type,'ordered:')">
<xsl:attribute name="start">
<xsl:value-of select="substring-after(@type,':')"/>
</xsl:attribute>
</xsl:if>
<xsl:apply-templates select="*[not(self::t:head or self::t:trailer)]"/>
</xsl:element>
<xsl:apply-templates select="t:trailer"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="t:item">
<xsl:choose>
<xsl:when test="parent::t:list[@type = 'catalogue']">
<xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
<li><xsl:apply-templates/></li>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- O -->
<xsl:template match="t:offset | t:measure | t:source ">
<xsl:if test="preceding-sibling::*">
<xsl:text> </xsl:text>
</xsl:if>
<xsl:apply-templates select="." mode="plain"/>
</xsl:template>
<!-- P -->
<xsl:template match="t:p">
<p>
<xsl:sequence select="local:attributes(.)"/>
<xsl:call-template name="rend"/>
</p>
</xsl:template>
<!-- Q -->
<xsl:template match="t:quote">
<span class="tei-quote" dir="ltr" lang="en"><xsl:choose>
<xsl:when test="@xml:lang">
<span dir="ltr"><xsl:text>“</xsl:text></span><span><xsl:sequence select="local:attributes(.)"/><xsl:call-template name="rend"/></span><span dir="ltr"><xsl:text>”</xsl:text></span>
</xsl:when>
<xsl:when test="parent::*/@xml:lang">
<span dir="ltr"><xsl:text>“</xsl:text></span><span class="langattr"><xsl:sequence select="local:attributes(parent::*[@xml:lang])"/><xsl:call-template name="rend"/></span><span dir="ltr"><xsl:text>”</xsl:text></span>
</xsl:when>
<xsl:otherwise>
<xsl:text>“</xsl:text><xsl:apply-templates/><xsl:text>”</xsl:text>
</xsl:otherwise>
</xsl:choose><!--<xsl:sequence select="local:add-footnotes(@source,ancestor::t:*[@xml:lang][1])"/>-->
<xsl:choose>
<xsl:when test="@source"><xsl:sequence select="local:add-footnotes(@source,ancestor::t:*[@xml:lang][1])"/></xsl:when>
<xsl:when test="parent::*[1]/@source"><xsl:sequence select="local:add-footnotes(parent::*[1]/@source,ancestor::t:*[@xml:lang][1])"/></xsl:when>
</xsl:choose>
</span>
</xsl:template>
<!-- R -->
<xsl:template match="t:ref | t:ptr">
<a href="{@target}">
<xsl:apply-templates/>
</a>
</xsl:template>
<!-- T -->
<xsl:template match="t:table">
<table class="tei-table">
<xsl:apply-templates/>
</table>
</xsl:template>
<!-- R -->
<xsl:template match="t:row">
<tr>
<xsl:apply-templates/>
</tr>
</xsl:template>
<!-- Default templates handle any element not specifically styled -->
<xsl:template match="*">
<span class="tei-{local-name(.)}">
<xsl:sequence select="local:attributes(.)"/>
<xsl:call-template name="rend"/>
<xsl:sequence select="local:add-footnotes(@source,.)"/>
</span>
</xsl:template>
<xsl:template match="t:*" mode="inline plain" xml:space="preserve">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="text()" mode="cleanout">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="t:*" mode="cleanout">
<xsl:apply-templates mode="cleanout"/>
</xsl:template>
<xsl:template match="t:*" mode="out-normal">
<xsl:variable name="thislang" select="ancestor-or-self::*[@xml:lang][1]/@xml:lang"/>
<xsl:choose>
<xsl:when test="starts-with($thislang, 'syr') or starts-with($thislang, 'syc') or starts-with($thislang, 'ar')">
<span dir="rtl">
<xsl:apply-templates select="." mode="text-normal"/>
</span>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="." mode="text-normal"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="t:*" mode="text-normal">
<xsl:value-of select="normalize-space(normalize-unicode(., $normalization))"/>
</xsl:template>
<xsl:template match="text()" mode="text-normal #default">
<xsl:variable name="prefix">
<xsl:if test="(preceding-sibling::t:* or preceding-sibling::text()[normalize-space()!='']) and string-length(.) > 0 and substring(., 1, 1)=' '">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:variable>
<xsl:variable name="suffix">
<xsl:if test="(following-sibling::t:* or following-sibling::text()[normalize-space()!='']) and string-length(.) > 0 and substring(., string-length(.), 1)=' '">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:variable>
<xsl:value-of select="$prefix"/>
<!--<xsl:value-of select="normalize-space(normalize-unicode(., $normalization))"/>-->
<xsl:value-of select="." disable-output-escaping="yes"/>
<xsl:value-of select="$suffix"/>
</xsl:template>
</xsl:stylesheet>