Mercurial > hg > mpdl-group
comparison software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageArchimedes.xsl @ 25:e9fe3186670c default tip
letzter Stand eingecheckt
author | Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 21 May 2013 10:19:32 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
23:e845310098ba | 25:e9fe3186670c |
---|---|
1 <?xml version="1.0"?> | |
2 <xsl:stylesheet version="2.0" | |
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
4 xmlns:xlink="http://www.w3.org/1999/xlink" | |
5 xmlns:xs="http://www.w3.org/2001/XMLSchema" | |
6 xmlns:functx="http://www.functx.com" | |
7 xmlns:saxon="http://saxon.sf.net/" | |
8 xmlns:dc="http://purl.org/dc/elements/1.1/" | |
9 xmlns:dcterms="http://purl.org/dc/terms" | |
10 xmlns:math="http://www.w3.org/1998/Math/MathML" | |
11 xmlns:svg="http://www.w3.org/2000/svg" | |
12 xmlns:xhtml="http://www.w3.org/1999/xhtml" | |
13 exclude-result-prefixes="xsl xlink xs functx saxon dc dcterms math svg xhtml" | |
14 > | |
15 | |
16 <xsl:output method="xhtml" encoding="utf-8"/> | |
17 | |
18 <xsl:param name="displayWordOptions"></xsl:param> | |
19 <xsl:param name="echoFiguresDir"></xsl:param> | |
20 <xsl:param name="echoPageImgDir"></xsl:param> | |
21 | |
22 <xsl:variable name="dictionaryServiceName" select="'http://mpdl-service.mpiwg-berlin.mpg.de/mpiwg-mpdl-lt-web/lt/GetDictionaryEntries'"/> | |
23 | |
24 <xsl:template match="*:archimedes"> | |
25 <div> | |
26 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if> | |
27 <xsl:attribute name="class"><xsl:value-of select="'archimedes'"/></xsl:attribute> | |
28 <xsl:apply-templates/> | |
29 </div> | |
30 </xsl:template> | |
31 | |
32 <xsl:template match="*:expan|*:emph|*:q|*:quote|*:blockquote|*:set-off|*:reg|*:var|*:num"> | |
33 <span> | |
34 <xsl:attribute name="class"><xsl:value-of select="name()"/></xsl:attribute> | |
35 <xsl:copy-of select="@*"/> | |
36 <xsl:apply-templates/> | |
37 </span> | |
38 </xsl:template> | |
39 | |
40 <xsl:template match="text"> | |
41 <xsl:variable name="contentStr" select="normalize-space(string(.))"/> | |
42 <xsl:variable name="figures" select=".//*:figure|.//*:handwritten"/> | |
43 <xsl:variable name="bottomNotes" select="//*:note"/> | |
44 <xsl:variable name="countBottomNotes" select="count($bottomNotes)"/> | |
45 <div> | |
46 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if> | |
47 <xsl:attribute name="class"><xsl:value-of select="'text'"/></xsl:attribute> | |
48 <xsl:apply-templates/> | |
49 <xsl:if test="$contentStr = '' and empty($figures)"> <!-- test if div only contains empty nodes but no figures --> | |
50 <div> | |
51 <xsl:attribute name="class"><xsl:value-of select="'emptyPage'"/></xsl:attribute> | |
52 <xsl:value-of select="'[Empty page]'"/> | |
53 </div> | |
54 </xsl:if> | |
55 <!-- Foot notes --> | |
56 <xsl:if test="$countBottomNotes > 0"> | |
57 <div class="notes foot"> | |
58 <xsl:for-each select="$bottomNotes"> | |
59 <xsl:variable name="noteSign"><xsl:value-of select="count(./preceding::*:note) + 1"/></xsl:variable> | |
60 <span> | |
61 <xsl:attribute name="id"><xsl:value-of select="$noteSign"/></xsl:attribute> | |
62 <xsl:attribute name="class"><xsl:value-of select="'note printed foot'"/></xsl:attribute> | |
63 <span class="noteSign"><xsl:value-of select="$noteSign"/></span> | |
64 <span> | |
65 <xsl:attribute name="class"><xsl:value-of select="'noteBody'"/></xsl:attribute> | |
66 <span class="noteSign"><xsl:value-of select="$noteSign"/></span> | |
67 <xsl:apply-templates/> | |
68 </span> | |
69 </span> | |
70 </xsl:for-each> | |
71 </div> | |
72 </xsl:if> | |
73 </div> | |
74 </xsl:template> | |
75 | |
76 <xsl:template match="*:div"> | |
77 <xsl:if test="node() or normalize-space()"> <!-- test: contains nodes or is not empty --> | |
78 <div> | |
79 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if> | |
80 <xsl:attribute name="class"><xsl:value-of select="'div'"/></xsl:attribute> | |
81 <xsl:apply-templates/> | |
82 </div> | |
83 </xsl:if> | |
84 </xsl:template> | |
85 | |
86 <xsl:template match="*:p"> | |
87 <xsl:variable name="type" select="string(@type)"/> | |
88 <div> | |
89 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if> | |
90 <xsl:choose> | |
91 <xsl:when test="$type = 'head'"> | |
92 <xsl:attribute name="class"><xsl:value-of select="'head bf'"/></xsl:attribute> | |
93 <xsl:apply-templates/> | |
94 </xsl:when> | |
95 <xsl:otherwise> | |
96 <xsl:attribute name="class"><xsl:value-of select="'p'"/></xsl:attribute> | |
97 <xsl:apply-templates/> | |
98 </xsl:otherwise> | |
99 </xsl:choose> | |
100 </div> | |
101 </xsl:template> | |
102 | |
103 <xsl:template match="*:pb"> | |
104 <xsl:variable name="number"> | |
105 <xsl:choose> | |
106 <xsl:when test="not(empty(@n))"><xsl:value-of select="@n"/></xsl:when> | |
107 <xsl:otherwise><xsl:value-of select="count(./preceding::*:pb) + 1"/></xsl:otherwise> | |
108 </xsl:choose> | |
109 </xsl:variable> | |
110 <xsl:variable name="file"> | |
111 <xsl:choose> | |
112 <xsl:when test="not(empty(@xlink:href))"><xsl:value-of select="replace(@xlink:href, '/', '.')"/></xsl:when> | |
113 <xsl:otherwise><xsl:value-of select="$number"/></xsl:otherwise> | |
114 </xsl:choose> | |
115 </xsl:variable> | |
116 <span> | |
117 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if> | |
118 <xsl:attribute name="class"><xsl:value-of select="'pb'"/></xsl:attribute> | |
119 <span> | |
120 <xsl:attribute name="class"><xsl:value-of select="'src'"/></xsl:attribute> | |
121 <xsl:attribute name="title"><xsl:value-of select="concat('pageimg/', string($file))"/></xsl:attribute> | |
122 <span> | |
123 <xsl:attribute name="class"><xsl:value-of select="'n'"/></xsl:attribute> | |
124 <xsl:value-of select="$number"/> | |
125 </span> | |
126 </span> | |
127 </span> | |
128 </xsl:template> | |
129 | |
130 <xsl:template match="*:head"> | |
131 <div> | |
132 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if> | |
133 <xsl:attribute name="class"><xsl:value-of select="'head bf'"/></xsl:attribute> | |
134 <xsl:apply-templates/> | |
135 </div> | |
136 </xsl:template> | |
137 | |
138 <!-- MathML --> | |
139 <xsl:template match="math:*"> | |
140 <xsl:element name="{name()}" namespace=""> | |
141 <xsl:copy-of select="@*"/> | |
142 <xsl:apply-templates/> | |
143 </xsl:element> | |
144 </xsl:template> | |
145 | |
146 <!-- SVG --> | |
147 <xsl:template match="svg:*"> | |
148 <xsl:element name="{name()}" namespace=""> | |
149 <xsl:copy-of select="@*"/> | |
150 <xsl:apply-templates/> | |
151 </xsl:element> | |
152 </xsl:template> | |
153 | |
154 <xsl:template match="*:figure"> | |
155 <span class="figure"> | |
156 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if> | |
157 <xsl:variable name="fileHref" select="replace(@xlink:href, '/', '.')"/> | |
158 <xsl:variable name="fileName" select="concat($echoFiguresDir, '/', $fileHref)"/> | |
159 <xsl:variable name="digilibUrl" select="concat('http://digilib.mpiwg-berlin.mpg.de/digitallibrary/jquery/digilib.html?fn=', $fileName)"/> | |
160 <xsl:variable name="scalerUrl" select="concat('http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler?fn=', $fileName, '&dh=200&dw=200')"/> | |
161 <xsl:variable name="ancestorWords" select="./ancestor::*:w"/> <!-- if figure is in a word then no link within a link should be produced --> | |
162 <xsl:choose> | |
163 <xsl:when test="empty($ancestorWords)"> | |
164 <a href="{$digilibUrl}"> | |
165 <img> | |
166 <xsl:attribute name="src"><xsl:value-of select="$scalerUrl"/></xsl:attribute> | |
167 </img> | |
168 </a> | |
169 </xsl:when> | |
170 <xsl:otherwise> | |
171 <img> | |
172 <xsl:attribute name="src"><xsl:value-of select="$scalerUrl"/></xsl:attribute> | |
173 </img> | |
174 </xsl:otherwise> | |
175 </xsl:choose> | |
176 <xsl:if test="not(empty(@number))"> | |
177 <span> | |
178 <xsl:attribute name="class"><xsl:value-of select="'figureNumber'"/></xsl:attribute> | |
179 <span> | |
180 <xsl:attribute name="class"><xsl:value-of select="'figureNum'"/></xsl:attribute> | |
181 <xsl:value-of select="string(@number)"/> | |
182 </span> | |
183 <span> | |
184 <xsl:attribute name="class"><xsl:value-of select="'figureNumText'"/></xsl:attribute> | |
185 <xsl:value-of select="concat('[', 'Figure', ' ', string(@number), ']')"/> | |
186 </span> | |
187 </span> | |
188 </xsl:if> | |
189 </span> | |
190 </xsl:template> | |
191 | |
192 <xsl:template match="*:lb"> | |
193 <br> | |
194 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if> | |
195 <xsl:attribute name="class"><xsl:value-of select="'lb'"/></xsl:attribute> | |
196 </br> | |
197 </xsl:template> | |
198 | |
199 <xsl:template match="*:cb"> | |
200 <br> | |
201 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if> | |
202 <xsl:attribute name="class"><xsl:value-of select="'cb'"/></xsl:attribute> | |
203 </br> | |
204 </xsl:template> | |
205 | |
206 <xsl:template match="note"> | |
207 <xsl:variable name="noteSign" select="count(./preceding::*:note) + 1"/> | |
208 <xsl:variable name="href" select="concat(urlBase, '#', $noteSign)"/> | |
209 <span> | |
210 <xsl:attribute name="class"><xsl:value-of select="'note printed foot'"/></xsl:attribute> | |
211 <span class="noteSign"><a href="{$href}"><xsl:value-of select="$noteSign"/></a></span> | |
212 </span> | |
213 </xsl:template> | |
214 | |
215 <xsl:template match="foreign"> | |
216 <xsl:variable name="lang" select="@lang"/> | |
217 <xsl:variable name="xmllang" select="@xml:lang"/> | |
218 <xsl:variable name="language"> | |
219 <xsl:choose> | |
220 <xsl:when test="not(empty($xmllang))"><xsl:value-of select="$xmllang"/></xsl:when> | |
221 <xsl:when test="not(empty($lang))"><xsl:value-of select="$lang"/></xsl:when> | |
222 <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise> | |
223 </xsl:choose> | |
224 </xsl:variable> | |
225 <span> | |
226 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if> | |
227 <xsl:attribute name="class"><xsl:value-of select="concat('foreign ', $language)"/></xsl:attribute> | |
228 <xsl:apply-templates/> | |
229 </span> | |
230 </xsl:template> | |
231 | |
232 <xsl:template match="gap"> | |
233 <span class="gap"> | |
234 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if> | |
235 <xsl:attribute name="class"><xsl:value-of select="'gap'"/></xsl:attribute> | |
236 <xsl:if test="not(empty(@extent))"><span class="extent"><xsl:value-of select="string(@extent)"/></span></xsl:if> | |
237 <xsl:apply-templates/> | |
238 </span> | |
239 </xsl:template> | |
240 | |
241 <xsl:template match="s"> | |
242 <span> | |
243 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if> | |
244 <xsl:attribute name="class"><xsl:value-of select="'s'"/></xsl:attribute> | |
245 <xsl:apply-templates/> | |
246 </span> | |
247 </xsl:template> | |
248 | |
249 <!-- words --> | |
250 <xsl:template match="*:w"> | |
251 <xsl:variable name="wordLanguage" select="@lang"/> | |
252 <xsl:variable name="form" select="encode-for-uri(string(@form))"/> | |
253 <xsl:variable name="dictionary" select="string(@dictionary)"/> | |
254 <xsl:variable name="displayWordOrig"> | |
255 <xsl:choose> | |
256 <xsl:when test="not(empty(*:orig))"><xsl:apply-templates select="*:orig/node()"/></xsl:when> | |
257 <xsl:otherwise><xsl:apply-templates/></xsl:otherwise> | |
258 </xsl:choose> | |
259 </xsl:variable> | |
260 <xsl:variable name="displayWordReg"> | |
261 <xsl:choose> | |
262 <xsl:when test="not(empty(*:reg))"><xsl:apply-templates select="*:reg/node()"/></xsl:when> | |
263 <xsl:otherwise><xsl:apply-templates/></xsl:otherwise> | |
264 </xsl:choose> | |
265 </xsl:variable> | |
266 <xsl:variable name="displayWordNorm"> | |
267 <xsl:choose> | |
268 <xsl:when test="not(empty(*:norm))"><xsl:apply-templates select="*:norm/node()"/></xsl:when> | |
269 <xsl:otherwise><xsl:apply-templates/></xsl:otherwise> | |
270 </xsl:choose> | |
271 </xsl:variable> | |
272 <xsl:variable name="displayWordUrlEncoded" select="encode-for-uri($displayWordOrig)"/> | |
273 <xsl:variable name="dictionaryPart"> | |
274 <xsl:choose> | |
275 <xsl:when test="$dictionary = 'true'"> | |
276 <a class="dictionary"> | |
277 <xsl:attribute name="href"><xsl:value-of select="concat($dictionaryServiceName, '?query=', $form, '&queryDisplay=', $displayWordUrlEncoded, '&language=', $wordLanguage, '&outputFormat=html', '&outputType=morphCompact&outputType=dictFull')"/></xsl:attribute> | |
278 <span class="orig"><xsl:sequence select="$displayWordOrig"/></span> | |
279 <span class="reg"><xsl:sequence select="$displayWordReg"/></span> | |
280 <span class="norm"><xsl:sequence select="$displayWordNorm"/></span> | |
281 </a> | |
282 </xsl:when> | |
283 <xsl:otherwise> | |
284 <span class="dictionary"> | |
285 <span class="orig"><xsl:sequence select="$displayWordOrig"/></span> | |
286 <span class="reg"><xsl:sequence select="$displayWordReg"/></span> | |
287 <span class="norm"><xsl:sequence select="$displayWordNorm"/></span> | |
288 </span> | |
289 </xsl:otherwise> | |
290 </xsl:choose> | |
291 </xsl:variable> | |
292 <xsl:variable name="displayWord"> | |
293 <xsl:choose> | |
294 <xsl:when test="$displayWordOptions = ''"> | |
295 <span class="w"> | |
296 <xsl:sequence select="$dictionaryPart"/> | |
297 <span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span> | |
298 <span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span> | |
299 <span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span> | |
300 </span> | |
301 </xsl:when> | |
302 <xsl:otherwise> | |
303 <span class="w"> | |
304 <xsl:if test="contains($displayWordOptions, 'dictionaryPart')"><xsl:sequence select="$dictionaryPart"/></xsl:if> | |
305 <xsl:if test="contains($displayWordOptions, 'orig')"><span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span></xsl:if> | |
306 <xsl:if test="contains($displayWordOptions, 'reg')"><span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span></xsl:if> | |
307 <xsl:if test="contains($displayWordOptions, 'norm')"><span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span></xsl:if> | |
308 </span> | |
309 </xsl:otherwise> | |
310 </xsl:choose> | |
311 </xsl:variable> | |
312 <xsl:sequence select="$displayWord"/> | |
313 </xsl:template> | |
314 | |
315 <xsl:template match="*:hi"> | |
316 <xsl:choose> | |
317 <xsl:when test="@type = 'elem'"> | |
318 <div> | |
319 <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute> | |
320 <xsl:apply-templates/> | |
321 </div> | |
322 </xsl:when> | |
323 <xsl:otherwise> | |
324 <span> | |
325 <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute> | |
326 <xsl:apply-templates/> | |
327 </span> | |
328 </xsl:otherwise> | |
329 </xsl:choose> | |
330 </xsl:template> | |
331 | |
332 </xsl:stylesheet> |