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