OLD | NEW |
| (Empty) |
1 <?xml version='1.0'?> | |
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
3 xmlns:xlink="http://www.w3.org/1999/xlink" | |
4 xmlns:stext="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.TextFac
tory" | |
5 xmlns:simg="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.ImageInt
rinsics" | |
6 xmlns:ximg="xalan://com.nwalsh.xalan.ImageIntrinsics" | |
7 xmlns:xtext="xalan://com.nwalsh.xalan.Text" | |
8 xmlns:lxslt="http://xml.apache.org/xslt" | |
9 exclude-result-prefixes="xlink stext xtext lxslt simg ximg" | |
10 extension-element-prefixes="stext xtext" | |
11 version='1.0'> | |
12 | |
13 <!-- ******************************************************************** | |
14 $Id: graphics.xsl 9660 2012-11-02 17:44:31Z bobstayton $ | |
15 ******************************************************************** | |
16 | |
17 This file is part of the XSL DocBook Stylesheet distribution. | |
18 See ../README or http://docbook.sf.net/release/xsl/current/ for | |
19 copyright and other information. | |
20 | |
21 Contributors: | |
22 Colin Paul Adams, <colin@colina.demon.co.uk> | |
23 | |
24 ******************************************************************** --> | |
25 | |
26 <lxslt:component prefix="xtext" elements="insertfile"/> | |
27 <lxslt:component prefix="ximg" functions="new getWidth getDepth"/> | |
28 | |
29 <!-- ==================================================================== --> | |
30 <!-- Graphic format tests for the HTML backend --> | |
31 | |
32 <xsl:template name="is.graphic.format"> | |
33 <xsl:param name="format"></xsl:param> | |
34 <xsl:if test="$format = 'SVG' | |
35 or $format = 'PNG' | |
36 or $format = 'JPG' | |
37 or $format = 'JPEG' | |
38 or $format = 'linespecific' | |
39 or $format = 'GIF' | |
40 or $format = 'GIF87a' | |
41 or $format = 'GIF89a' | |
42 or $format = 'BMP'">1</xsl:if> | |
43 </xsl:template> | |
44 | |
45 <xsl:template name="is.graphic.extension"> | |
46 <xsl:param name="ext"></xsl:param> | |
47 <xsl:variable name="lcext" select="translate($ext, | |
48 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', | |
49 'abcdefghijklmnopqrstuvwxyz')"/> | |
50 <xsl:if test="$lcext = 'svg' | |
51 or $lcext = 'png' | |
52 or $lcext = 'jpeg' | |
53 or $lcext = 'jpg' | |
54 or $lcext = 'avi' | |
55 or $lcext = 'mpg' | |
56 or $lcext = 'mp4' | |
57 or $lcext = 'mpeg' | |
58 or $lcext = 'qt' | |
59 or $lcext = 'gif' | |
60 or $lcext = 'acc' | |
61 or $lcext = 'mp1' | |
62 or $lcext = 'mp2' | |
63 or $lcext = 'mp3' | |
64 or $lcext = 'mp4' | |
65 or $lcext = 'm4v' | |
66 or $lcext = 'm4a' | |
67 or $lcext = 'wav' | |
68 or $lcext = 'ogv' | |
69 or $lcext = 'ogg' | |
70 or $lcext = 'webm' | |
71 or $lcext = 'bmp'">1</xsl:if> | |
72 </xsl:template> | |
73 | |
74 <!-- ==================================================================== --> | |
75 | |
76 <xsl:template match="screenshot"> | |
77 <div> | |
78 <xsl:apply-templates select="." mode="common.html.attributes"/> | |
79 <xsl:call-template name="id.attribute"/> | |
80 <xsl:call-template name="anchor"/> | |
81 <xsl:apply-templates/> | |
82 </div> | |
83 </xsl:template> | |
84 | |
85 <xsl:template match="screenshot/title"> | |
86 <xsl:call-template name="formal.object.heading"> | |
87 <xsl:with-param name="object" select=".."/> | |
88 </xsl:call-template> | |
89 </xsl:template> | |
90 | |
91 <xsl:template match="screeninfo"> | |
92 </xsl:template> | |
93 | |
94 <!-- ==================================================================== --> | |
95 | |
96 <xsl:template name="process.image"> | |
97 <!-- When this template is called, the current node should be --> | |
98 <!-- a graphic, inlinegraphic, imagedata, or videodata. All --> | |
99 <!-- those elements have the same set of attributes, so we can --> | |
100 <!-- handle them all in one place. --> | |
101 <xsl:param name="tag" select="'img'"/> | |
102 <xsl:param name="alt"/> | |
103 <xsl:param name="longdesc"/> | |
104 | |
105 <!-- The HTML img element only supports the notion of content-area | |
106 scaling; it doesn't support the distinction between a | |
107 content-area and a viewport-area, so we have to make some | |
108 compromises. | |
109 | |
110 1. If only the content-area is specified, everything is fine. | |
111 (If you ask for a three inch image, that's what you'll get.) | |
112 | |
113 2. If only the viewport-area is provided: | |
114 - If scalefit=1, treat it as both the content-area and | |
115 the viewport-area. (If you ask for an image in a five inch | |
116 area, we'll make the image five inches to fill that area.) | |
117 - If scalefit=0, ignore the viewport-area specification. | |
118 | |
119 Note: this is not quite the right semantic and has the additional | |
120 problem that it can result in anamorphic scaling, which scalefit | |
121 should never cause. | |
122 | |
123 3. If both the content-area and the viewport-area is specified | |
124 on a graphic element, ignore the viewport-area. | |
125 (If you ask for a three inch image in a five inch area, we'll assume | |
126 it's better to give you a three inch image in an unspecified area | |
127 than a five inch image in a five inch area. | |
128 | |
129 Relative units also cause problems. As a general rule, the stylesheets | |
130 are operating too early and too loosely coupled with the rendering engine | |
131 to know things like the current font size or the actual dimensions of | |
132 an image. Therefore: | |
133 | |
134 1. We use a fixed size for pixels, $pixels.per.inch | |
135 | |
136 2. We use a fixed size for "em"s, $points.per.em | |
137 | |
138 Percentages are problematic. In the following discussion, we speak | |
139 of width and contentwidth, but the same issues apply to depth and | |
140 contentdepth | |
141 | |
142 1. A width of 50% means "half of the available space for the image." | |
143 That's fine. But note that in HTML, this is a dynamic property and | |
144 the image size will vary if the browser window is resized. | |
145 | |
146 2. A contentwidth of 50% means "half of the actual image width". But | |
147 the stylesheets have no way to assess the image's actual size. Treatin
g | |
148 this as a width of 50% is one possibility, but it produces behavior | |
149 (dynamic scaling) that seems entirely out of character with the | |
150 meaning. | |
151 | |
152 Instead, the stylesheets define a $nominal.image.width | |
153 and convert percentages to actual values based on that nominal size. | |
154 | |
155 Scale can be problematic. Scale applies to the contentwidth, so | |
156 a scale of 50 when a contentwidth is not specified is analagous to a | |
157 width of 50%. (If a contentwidth is specified, the scaling factor can | |
158 be applied to that value and no problem exists.) | |
159 | |
160 If scale is specified but contentwidth is not supplied, the | |
161 nominal.image.width is used to calculate a base size | |
162 for scaling. | |
163 | |
164 Warning: as a consequence of these decisions, unless the aspect ratio | |
165 of your image happens to be exactly the same as (nominal width / nominal
height), | |
166 specifying contentwidth="50%" and contentdepth="50%" is NOT going to | |
167 scale the way you expect (or really, the way it should). | |
168 | |
169 Don't do that. In fact, a percentage value is not recommended for content | |
170 size at all. Use scale instead. | |
171 | |
172 Finally, align and valign are troublesome. Horizontal alignment is now | |
173 supported by wrapping the image in a <div align="{@align}"> (in block | |
174 contexts!). I can't think of anything (practical) to do about vertical | |
175 alignment. | |
176 --> | |
177 | |
178 <xsl:variable name="width-units"> | |
179 <xsl:choose> | |
180 <xsl:when test="$ignore.image.scaling != 0"></xsl:when> | |
181 <xsl:when test="@width"> | |
182 <xsl:call-template name="length-units"> | |
183 <xsl:with-param name="length" select="@width"/> | |
184 </xsl:call-template> | |
185 </xsl:when> | |
186 <xsl:when test="not(@depth) and $default.image.width != ''"> | |
187 <xsl:call-template name="length-units"> | |
188 <xsl:with-param name="length" select="$default.image.width"/> | |
189 </xsl:call-template> | |
190 </xsl:when> | |
191 </xsl:choose> | |
192 </xsl:variable> | |
193 | |
194 <xsl:variable name="width"> | |
195 <xsl:choose> | |
196 <xsl:when test="$ignore.image.scaling != 0"></xsl:when> | |
197 <xsl:when test="@width"> | |
198 <xsl:choose> | |
199 <xsl:when test="$width-units = '%'"> | |
200 <xsl:value-of select="@width"/> | |
201 </xsl:when> | |
202 <xsl:otherwise> | |
203 <xsl:call-template name="length-spec"> | |
204 <xsl:with-param name="length" select="@width"/> | |
205 </xsl:call-template> | |
206 </xsl:otherwise> | |
207 </xsl:choose> | |
208 </xsl:when> | |
209 <xsl:when test="not(@depth) and $default.image.width != ''"> | |
210 <xsl:value-of select="$default.image.width"/> | |
211 </xsl:when> | |
212 </xsl:choose> | |
213 </xsl:variable> | |
214 | |
215 <xsl:variable name="scalefit"> | |
216 <xsl:choose> | |
217 <xsl:when test="$ignore.image.scaling != 0">0</xsl:when> | |
218 <xsl:when test="@contentwidth or @contentdepth">0</xsl:when> | |
219 <xsl:when test="@scale">0</xsl:when> | |
220 <xsl:when test="@scalefit"><xsl:value-of select="@scalefit"/></xsl:when> | |
221 <xsl:when test="$width != '' or @depth">1</xsl:when> | |
222 <xsl:otherwise>0</xsl:otherwise> | |
223 </xsl:choose> | |
224 </xsl:variable> | |
225 | |
226 <xsl:variable name="scale"> | |
227 <xsl:choose> | |
228 <xsl:when test="$ignore.image.scaling != 0">1.0</xsl:when> | |
229 <xsl:when test="@contentwidth or @contentdepth">1.0</xsl:when> | |
230 <xsl:when test="@scale"> | |
231 <xsl:value-of select="@scale div 100.0"/> | |
232 </xsl:when> | |
233 <xsl:otherwise>1.0</xsl:otherwise> | |
234 </xsl:choose> | |
235 </xsl:variable> | |
236 | |
237 <xsl:variable name="filename"> | |
238 <xsl:choose> | |
239 <xsl:when test="local-name(.) = 'graphic' | |
240 or local-name(.) = 'inlinegraphic'"> | |
241 <!-- handle legacy graphic and inlinegraphic by new template --> | |
242 <xsl:call-template name="mediaobject.filename"> | |
243 <xsl:with-param name="object" select="."/> | |
244 </xsl:call-template> | |
245 </xsl:when> | |
246 <xsl:otherwise> | |
247 <!-- imagedata, videodata, audiodata --> | |
248 <xsl:call-template name="mediaobject.filename"> | |
249 <xsl:with-param name="object" select=".."/> | |
250 </xsl:call-template> | |
251 </xsl:otherwise> | |
252 </xsl:choose> | |
253 </xsl:variable> | |
254 | |
255 <xsl:variable name="output_filename"> | |
256 <xsl:choose> | |
257 <xsl:when test="@entityref"> | |
258 <xsl:value-of select="$filename"/> | |
259 </xsl:when> | |
260 <!-- | |
261 Moved test for $keep.relative.image.uris to template below: | |
262 <xsl:template match="@fileref"> | |
263 --> | |
264 <xsl:otherwise> | |
265 <xsl:value-of select="$filename"/> | |
266 </xsl:otherwise> | |
267 </xsl:choose> | |
268 </xsl:variable> | |
269 | |
270 <xsl:variable name="img.src.path.pi"> | |
271 <xsl:call-template name="pi.dbhtml_img.src.path"> | |
272 <xsl:with-param name="node" select=".."/> | |
273 </xsl:call-template> | |
274 </xsl:variable> | |
275 | |
276 <xsl:variable name="filename.for.graphicsize"> | |
277 <xsl:choose> | |
278 <xsl:when test="$img.src.path.pi != ''"> | |
279 <xsl:value-of select="concat($img.src.path.pi, $filename)"/> | |
280 </xsl:when> | |
281 <xsl:when test="$img.src.path != '' and | |
282 $graphicsize.use.img.src.path != 0 and | |
283 $tag = 'img' and | |
284 not(starts-with($filename, '/')) and | |
285 not(contains($filename, '://'))"> | |
286 <xsl:value-of select="concat($img.src.path, $filename)"/> | |
287 </xsl:when> | |
288 <xsl:otherwise> | |
289 <xsl:value-of select="$filename"/> | |
290 </xsl:otherwise> | |
291 </xsl:choose> | |
292 </xsl:variable> | |
293 | |
294 <xsl:variable name="realintrinsicwidth"> | |
295 <!-- This funny compound test works around a bug in XSLTC --> | |
296 <xsl:choose> | |
297 <xsl:when test="$use.extensions != 0 and $graphicsize.extension != 0 | |
298 and not(@format='SVG')"> | |
299 <xsl:choose> | |
300 <xsl:when test="function-available('simg:getWidth')"> | |
301 <xsl:value-of select="simg:getWidth(simg:new($filename.for.graphicsi
ze), | |
302 $nominal.image.width)"/> | |
303 </xsl:when> | |
304 <xsl:when test="function-available('ximg:getWidth')"> | |
305 <xsl:value-of select="ximg:getWidth(ximg:new($filename.for.graphicsi
ze), | |
306 $nominal.image.width)"/> | |
307 </xsl:when> | |
308 <xsl:otherwise> | |
309 <xsl:value-of select="0"/> | |
310 </xsl:otherwise> | |
311 </xsl:choose> | |
312 </xsl:when> | |
313 <xsl:otherwise> | |
314 <xsl:value-of select="0"/> | |
315 </xsl:otherwise> | |
316 </xsl:choose> | |
317 </xsl:variable> | |
318 | |
319 <xsl:variable name="intrinsicwidth"> | |
320 <xsl:choose> | |
321 <xsl:when test="$realintrinsicwidth = 0"> | |
322 <xsl:value-of select="$nominal.image.width"/> | |
323 </xsl:when> | |
324 <xsl:otherwise> | |
325 <xsl:value-of select="$realintrinsicwidth"/> | |
326 </xsl:otherwise> | |
327 </xsl:choose> | |
328 </xsl:variable> | |
329 | |
330 <xsl:variable name="intrinsicdepth"> | |
331 <!-- This funny compound test works around a bug in XSLTC --> | |
332 <xsl:choose> | |
333 <xsl:when test="$use.extensions != 0 and $graphicsize.extension != 0 | |
334 and not(@format='SVG')"> | |
335 <xsl:choose> | |
336 <xsl:when test="function-available('simg:getDepth')"> | |
337 <xsl:value-of select="simg:getDepth(simg:new($filename.for.graphicsi
ze), | |
338 $nominal.image.depth)"/> | |
339 </xsl:when> | |
340 <xsl:when test="function-available('ximg:getDepth')"> | |
341 <xsl:value-of select="ximg:getDepth(ximg:new($filename.for.graphicsi
ze), | |
342 $nominal.image.depth)"/> | |
343 </xsl:when> | |
344 <xsl:otherwise> | |
345 <xsl:value-of select="$nominal.image.depth"/> | |
346 </xsl:otherwise> | |
347 </xsl:choose> | |
348 </xsl:when> | |
349 <xsl:otherwise> | |
350 <xsl:value-of select="$nominal.image.depth"/> | |
351 </xsl:otherwise> | |
352 </xsl:choose> | |
353 </xsl:variable> | |
354 | |
355 <xsl:variable name="contentwidth"> | |
356 <xsl:choose> | |
357 <xsl:when test="$ignore.image.scaling != 0"></xsl:when> | |
358 <xsl:when test="@contentwidth"> | |
359 <xsl:variable name="units"> | |
360 <xsl:call-template name="length-units"> | |
361 <xsl:with-param name="length" select="@contentwidth"/> | |
362 </xsl:call-template> | |
363 </xsl:variable> | |
364 | |
365 <xsl:choose> | |
366 <xsl:when test="$units = '%'"> | |
367 <xsl:variable name="cmagnitude"> | |
368 <xsl:call-template name="length-magnitude"> | |
369 <xsl:with-param name="length" select="@contentwidth"/> | |
370 </xsl:call-template> | |
371 </xsl:variable> | |
372 <xsl:value-of select="$intrinsicwidth * $cmagnitude div 100.0"/> | |
373 <xsl:text>px</xsl:text> | |
374 </xsl:when> | |
375 <xsl:otherwise> | |
376 <xsl:call-template name="length-spec"> | |
377 <xsl:with-param name="length" select="@contentwidth"/> | |
378 </xsl:call-template> | |
379 </xsl:otherwise> | |
380 </xsl:choose> | |
381 </xsl:when> | |
382 <xsl:otherwise> | |
383 <xsl:value-of select="$intrinsicwidth"/> | |
384 <xsl:text>px</xsl:text> | |
385 </xsl:otherwise> | |
386 </xsl:choose> | |
387 </xsl:variable> | |
388 | |
389 <xsl:variable name="scaled.contentwidth"> | |
390 <xsl:if test="$contentwidth != ''"> | |
391 <xsl:variable name="cwidth.in.points"> | |
392 <xsl:call-template name="length-in-points"> | |
393 <xsl:with-param name="length" select="$contentwidth"/> | |
394 <xsl:with-param name="pixels.per.inch" select="$pixels.per.inch"/> | |
395 <xsl:with-param name="em.size" select="$points.per.em"/> | |
396 </xsl:call-template> | |
397 </xsl:variable> | |
398 <xsl:value-of select="$cwidth.in.points div 72.0 * $pixels.per.inch * $sca
le"/> | |
399 </xsl:if> | |
400 </xsl:variable> | |
401 | |
402 <xsl:variable name="html.width"> | |
403 <xsl:choose> | |
404 <xsl:when test="$ignore.image.scaling != 0"></xsl:when> | |
405 <xsl:when test="$width-units = '%'"> | |
406 <xsl:value-of select="$width"/> | |
407 </xsl:when> | |
408 <xsl:when test="$width != ''"> | |
409 <xsl:variable name="width.in.points"> | |
410 <xsl:call-template name="length-in-points"> | |
411 <xsl:with-param name="length" select="$width"/> | |
412 <xsl:with-param name="pixels.per.inch" select="$pixels.per.inch"/> | |
413 <xsl:with-param name="em.size" select="$points.per.em"/> | |
414 </xsl:call-template> | |
415 </xsl:variable> | |
416 <xsl:value-of select="round($width.in.points div 72.0 * $pixels.per.inch
)"/> | |
417 </xsl:when> | |
418 <xsl:otherwise></xsl:otherwise> | |
419 </xsl:choose> | |
420 </xsl:variable> | |
421 | |
422 <xsl:variable name="contentdepth"> | |
423 <xsl:choose> | |
424 <xsl:when test="$ignore.image.scaling != 0"></xsl:when> | |
425 <xsl:when test="@contentdepth"> | |
426 <xsl:variable name="units"> | |
427 <xsl:call-template name="length-units"> | |
428 <xsl:with-param name="length" select="@contentdepth"/> | |
429 </xsl:call-template> | |
430 </xsl:variable> | |
431 | |
432 <xsl:choose> | |
433 <xsl:when test="$units = '%'"> | |
434 <xsl:variable name="cmagnitude"> | |
435 <xsl:call-template name="length-magnitude"> | |
436 <xsl:with-param name="length" select="@contentdepth"/> | |
437 </xsl:call-template> | |
438 </xsl:variable> | |
439 <xsl:value-of select="$intrinsicdepth * $cmagnitude div 100.0"/> | |
440 <xsl:text>px</xsl:text> | |
441 </xsl:when> | |
442 <xsl:otherwise> | |
443 <xsl:call-template name="length-spec"> | |
444 <xsl:with-param name="length" select="@contentdepth"/> | |
445 </xsl:call-template> | |
446 </xsl:otherwise> | |
447 </xsl:choose> | |
448 </xsl:when> | |
449 <xsl:otherwise> | |
450 <xsl:value-of select="$intrinsicdepth"/> | |
451 <xsl:text>px</xsl:text> | |
452 </xsl:otherwise> | |
453 </xsl:choose> | |
454 </xsl:variable> | |
455 | |
456 <xsl:variable name="scaled.contentdepth"> | |
457 <xsl:if test="$contentdepth != ''"> | |
458 <xsl:variable name="cdepth.in.points"> | |
459 <xsl:call-template name="length-in-points"> | |
460 <xsl:with-param name="length" select="$contentdepth"/> | |
461 <xsl:with-param name="pixels.per.inch" select="$pixels.per.inch"/> | |
462 <xsl:with-param name="em.size" select="$points.per.em"/> | |
463 </xsl:call-template> | |
464 </xsl:variable> | |
465 <xsl:value-of select="$cdepth.in.points div 72.0 * $pixels.per.inch * $sca
le"/> | |
466 </xsl:if> | |
467 </xsl:variable> | |
468 | |
469 <xsl:variable name="depth-units"> | |
470 <xsl:if test="@depth"> | |
471 <xsl:call-template name="length-units"> | |
472 <xsl:with-param name="length" select="@depth"/> | |
473 </xsl:call-template> | |
474 </xsl:if> | |
475 </xsl:variable> | |
476 | |
477 <xsl:variable name="depth"> | |
478 <xsl:if test="@depth"> | |
479 <xsl:choose> | |
480 <xsl:when test="$depth-units = '%'"> | |
481 <xsl:value-of select="@depth"/> | |
482 </xsl:when> | |
483 <xsl:otherwise> | |
484 <xsl:call-template name="length-spec"> | |
485 <xsl:with-param name="length" select="@depth"/> | |
486 </xsl:call-template> | |
487 </xsl:otherwise> | |
488 </xsl:choose> | |
489 </xsl:if> | |
490 </xsl:variable> | |
491 | |
492 <xsl:variable name="html.depth"> | |
493 <xsl:choose> | |
494 <xsl:when test="$ignore.image.scaling != 0"></xsl:when> | |
495 <xsl:when test="$depth-units = '%'"> | |
496 <xsl:value-of select="$depth"/> | |
497 </xsl:when> | |
498 <xsl:when test="@depth and @depth != ''"> | |
499 <xsl:variable name="depth.in.points"> | |
500 <xsl:call-template name="length-in-points"> | |
501 <xsl:with-param name="length" select="$depth"/> | |
502 <xsl:with-param name="pixels.per.inch" select="$pixels.per.inch"/> | |
503 <xsl:with-param name="em.size" select="$points.per.em"/> | |
504 </xsl:call-template> | |
505 </xsl:variable> | |
506 <xsl:value-of select="round($depth.in.points div 72.0 * $pixels.per.inch
)"/> | |
507 </xsl:when> | |
508 <xsl:otherwise></xsl:otherwise> | |
509 </xsl:choose> | |
510 </xsl:variable> | |
511 | |
512 <xsl:variable name="viewport"> | |
513 <xsl:choose> | |
514 <xsl:when test="$ignore.image.scaling != 0">0</xsl:when> | |
515 <xsl:when test="local-name(.) = 'inlinegraphic' | |
516 or ancestor::inlinemediaobject | |
517 or ancestor::inlineequation">0</xsl:when> | |
518 <xsl:otherwise> | |
519 <xsl:value-of select="$make.graphic.viewport"/> | |
520 </xsl:otherwise> | |
521 </xsl:choose> | |
522 </xsl:variable> | |
523 | |
524 <!-- | |
525 <xsl:message>===================================== | |
526 scale: <xsl:value-of select="$scale"/>, <xsl:value-of select="$scalefit"/> | |
527 @contentwidth <xsl:value-of select="@contentwidth"/> | |
528 $contentwidth <xsl:value-of select="$contentwidth"/> | |
529 scaled.contentwidth: <xsl:value-of select="$scaled.contentwidth"/> | |
530 @width: <xsl:value-of select="@width"/> | |
531 width: <xsl:value-of select="$width"/> | |
532 html.width: <xsl:value-of select="$html.width"/> | |
533 @contentdepth <xsl:value-of select="@contentdepth"/> | |
534 $contentdepth <xsl:value-of select="$contentdepth"/> | |
535 scaled.contentdepth: <xsl:value-of select="$scaled.contentdepth"/> | |
536 @depth: <xsl:value-of select="@depth"/> | |
537 depth: <xsl:value-of select="$depth"/> | |
538 html.depth: <xsl:value-of select="$html.depth"/> | |
539 align: <xsl:value-of select="@align"/> | |
540 valign: <xsl:value-of select="@valign"/></xsl:message> | |
541 --> | |
542 | |
543 <xsl:variable name="scaled" | |
544 select="@width|@depth|@contentwidth|@contentdepth | |
545 |@scale|@scalefit"/> | |
546 | |
547 <xsl:variable name="img"> | |
548 <xsl:choose> | |
549 <xsl:when test="@format = 'SVG'"> | |
550 <object type="image/svg+xml"> | |
551 <xsl:attribute name="data"> | |
552 <xsl:choose> | |
553 <xsl:when test="$img.src.path != '' and | |
554 $tag = 'img' and | |
555 not(starts-with($output_filename, '/')) and | |
556 not(contains($output_filename, '://'))"> | |
557 <xsl:value-of select="$img.src.path"/> | |
558 </xsl:when> | |
559 </xsl:choose> | |
560 <xsl:value-of select="$output_filename"/> | |
561 </xsl:attribute> | |
562 <xsl:call-template name="process.image.attributes"> | |
563 <!--xsl:with-param name="alt" select="$alt"/ there's no alt here--> | |
564 <xsl:with-param name="html.depth" select="$html.depth"/> | |
565 <xsl:with-param name="html.width" select="$html.width"/> | |
566 <xsl:with-param name="longdesc" select="$longdesc"/> | |
567 <xsl:with-param name="scale" select="$scale"/> | |
568 <xsl:with-param name="scalefit" select="$scalefit"/> | |
569 <xsl:with-param name="scaled.contentdepth" select="$scaled.contentde
pth"/> | |
570 <xsl:with-param name="scaled.contentwidth" select="$scaled.contentwi
dth"/> | |
571 <xsl:with-param name="viewport" select="$viewport"/> | |
572 </xsl:call-template> | |
573 <xsl:if test="@align"> | |
574 <xsl:attribute name="align"> | |
575 <xsl:choose> | |
576 <xsl:when test="@align = 'center'">middle</xsl:when> | |
577 <xsl:otherwise> | |
578 <xsl:value-of select="@align"/> | |
579 </xsl:otherwise> | |
580 </xsl:choose> | |
581 </xsl:attribute> | |
582 </xsl:if> | |
583 <xsl:if test="$use.embed.for.svg != 0"> | |
584 <embed type="image/svg+xml"> | |
585 <xsl:attribute name="src"> | |
586 <xsl:choose> | |
587 <xsl:when test="$img.src.path != '' and | |
588 $tag = 'img' and | |
589 not(starts-with($output_filename, '/')) and | |
590 not(contains($output_filename, '://'))"> | |
591 <xsl:value-of select="$img.src.path"/> | |
592 </xsl:when> | |
593 </xsl:choose> | |
594 <xsl:value-of select="$output_filename"/> | |
595 </xsl:attribute> | |
596 <xsl:call-template name="process.image.attributes"> | |
597 <!--xsl:with-param name="alt" select="$alt"/ there's no alt here
--> | |
598 <xsl:with-param name="html.depth" select="$html.depth"/> | |
599 <xsl:with-param name="html.width" select="$html.width"/> | |
600 <xsl:with-param name="longdesc" select="$longdesc"/> | |
601 <xsl:with-param name="scale" select="$scale"/> | |
602 <xsl:with-param name="scalefit" select="$scalefit"/> | |
603 <xsl:with-param name="scaled.contentdepth" select="$scaled.conte
ntdepth"/> | |
604 <xsl:with-param name="scaled.contentwidth" select="$scaled.conte
ntwidth"/> | |
605 <xsl:with-param name="viewport" select="$viewport"/> | |
606 </xsl:call-template> | |
607 </embed> | |
608 </xsl:if> | |
609 </object> | |
610 </xsl:when> | |
611 <xsl:otherwise> | |
612 <xsl:element name="{$tag}"> | |
613 <xsl:if test="$tag = 'img' and ../../self::imageobjectco"> | |
614 <xsl:variable name="mapname"> | |
615 <xsl:call-template name="object.id"> | |
616 <xsl:with-param name="object" select="../../areaspec"/> | |
617 </xsl:call-template> | |
618 </xsl:variable> | |
619 <xsl:choose> | |
620 <xsl:when test="$scaled"> | |
621 <!-- It might be possible to handle some scaling; needs --> | |
622 <!-- more investigation --> | |
623 <xsl:message> | |
624 <xsl:text>Warning: imagemaps not supported </xsl:text> | |
625 <xsl:text>on scaled images</xsl:text> | |
626 </xsl:message> | |
627 </xsl:when> | |
628 <xsl:otherwise> | |
629 <xsl:attribute name="border">0</xsl:attribute> | |
630 <xsl:attribute name="usemap"> | |
631 <xsl:value-of select="concat('#', $mapname)"/> | |
632 </xsl:attribute> | |
633 </xsl:otherwise> | |
634 </xsl:choose> | |
635 </xsl:if> | |
636 | |
637 <xsl:attribute name="src"> | |
638 <xsl:choose> | |
639 <xsl:when test="$img.src.path != '' and | |
640 $tag = 'img' and | |
641 not(starts-with($output_filename, '/')) and | |
642 not(contains($output_filename, '://'))"> | |
643 <xsl:value-of select="$img.src.path"/> | |
644 </xsl:when> | |
645 </xsl:choose> | |
646 <xsl:value-of select="$output_filename"/> | |
647 </xsl:attribute> | |
648 | |
649 <xsl:if test="@align"> | |
650 <xsl:attribute name="align"> | |
651 <xsl:choose> | |
652 <xsl:when test="@align = 'center'">middle</xsl:when> | |
653 <xsl:otherwise> | |
654 <xsl:value-of select="@align"/> | |
655 </xsl:otherwise> | |
656 </xsl:choose> | |
657 </xsl:attribute> | |
658 </xsl:if> | |
659 | |
660 <xsl:call-template name="process.image.attributes"> | |
661 <xsl:with-param name="alt"> | |
662 <xsl:choose> | |
663 <xsl:when test="$alt != ''"> | |
664 <xsl:copy-of select="$alt"/> | |
665 </xsl:when> | |
666 <xsl:when test="ancestor::figure"> | |
667 <xsl:variable name="fig.title"> | |
668 <xsl:apply-templates select="ancestor::figure/title/node()"/
> | |
669 </xsl:variable> | |
670 <xsl:value-of select="normalize-space($fig.title)"/> | |
671 </xsl:when> | |
672 </xsl:choose> | |
673 </xsl:with-param> | |
674 <xsl:with-param name="html.depth" select="$html.depth"/> | |
675 <xsl:with-param name="html.width" select="$html.width"/> | |
676 <xsl:with-param name="longdesc" select="$longdesc"/> | |
677 <xsl:with-param name="scale" select="$scale"/> | |
678 <xsl:with-param name="scalefit" select="$scalefit"/> | |
679 <xsl:with-param name="scaled.contentdepth" select="$scaled.contentde
pth"/> | |
680 <xsl:with-param name="scaled.contentwidth" select="$scaled.contentwi
dth"/> | |
681 <xsl:with-param name="viewport" select="$viewport"/> | |
682 </xsl:call-template> | |
683 </xsl:element> | |
684 </xsl:otherwise> | |
685 </xsl:choose> | |
686 </xsl:variable> | |
687 | |
688 <xsl:variable name="bgcolor"> | |
689 <xsl:call-template name="pi.dbhtml_background-color"> | |
690 <xsl:with-param name="node" select=".."/> | |
691 </xsl:call-template> | |
692 </xsl:variable> | |
693 | |
694 <xsl:variable name="use.viewport" | |
695 select="$viewport != 0 | |
696 and ($html.width != '' | |
697 or ($html.depth != '' and $depth-units != '%') | |
698 or $bgcolor != '' | |
699 or @valign)"/> | |
700 | |
701 <xsl:choose> | |
702 <xsl:when test="$use.viewport"> | |
703 <table border="{$table.border.off}"> | |
704 <xsl:if test="$div.element != 'section'"> | |
705 <xsl:attribute name="summary">manufactured viewport for HTML img</xsl:
attribute> | |
706 </xsl:if> | |
707 <xsl:if test="$css.decoration != ''"> | |
708 <xsl:attribute name="style">cellpadding: 0; cellspacing: 0;</xsl:attri
bute> | |
709 </xsl:if> | |
710 <xsl:if test="$html.width != ''"> | |
711 <xsl:attribute name="width"> | |
712 <xsl:value-of select="$html.width"/> | |
713 </xsl:attribute> | |
714 </xsl:if> | |
715 <tr> | |
716 <xsl:if test="$html.depth != '' and $depth-units != '%'"> | |
717 <!-- don't do this for percentages because browsers get confused --> | |
718 <xsl:choose> | |
719 <xsl:when test="$css.decoration != 0"> | |
720 <xsl:attribute name="style"> | |
721 <xsl:text>height: </xsl:text> | |
722 <xsl:value-of select="$html.depth"/> | |
723 <xsl:text>px</xsl:text> | |
724 </xsl:attribute> | |
725 </xsl:when> | |
726 <xsl:otherwise> | |
727 <xsl:attribute name="height"> | |
728 <xsl:value-of select="$html.depth"/> | |
729 </xsl:attribute> | |
730 </xsl:otherwise> | |
731 </xsl:choose> | |
732 </xsl:if> | |
733 <td> | |
734 <xsl:if test="$bgcolor != ''"> | |
735 <xsl:choose> | |
736 <xsl:when test="$css.decoration != 0"> | |
737 <xsl:attribute name="style"> | |
738 <xsl:text>background-color: </xsl:text> | |
739 <xsl:value-of select="$bgcolor"/> | |
740 </xsl:attribute> | |
741 </xsl:when> | |
742 <xsl:otherwise> | |
743 <xsl:attribute name="bgcolor"> | |
744 <xsl:value-of select="$bgcolor"/> | |
745 </xsl:attribute> | |
746 </xsl:otherwise> | |
747 </xsl:choose> | |
748 </xsl:if> | |
749 <xsl:if test="@align"> | |
750 <xsl:attribute name="align"> | |
751 <xsl:value-of select="@align"/> | |
752 </xsl:attribute> | |
753 </xsl:if> | |
754 <xsl:if test="@valign"> | |
755 <xsl:attribute name="valign"> | |
756 <xsl:value-of select="@valign"/> | |
757 </xsl:attribute> | |
758 </xsl:if> | |
759 <xsl:copy-of select="$img"/> | |
760 </td> | |
761 </tr> | |
762 </table> | |
763 </xsl:when> | |
764 <xsl:otherwise> | |
765 <xsl:copy-of select="$img"/> | |
766 </xsl:otherwise> | |
767 </xsl:choose> | |
768 | |
769 <xsl:if test="$tag = 'img' and ../../self::imageobjectco and not($scaled)"> | |
770 <xsl:variable name="mapname"> | |
771 <xsl:call-template name="object.id"> | |
772 <xsl:with-param name="object" select="../../areaspec"/> | |
773 </xsl:call-template> | |
774 </xsl:variable> | |
775 | |
776 <map name="{$mapname}"> | |
777 <xsl:for-each select="../../areaspec//area"> | |
778 <xsl:variable name="units"> | |
779 <xsl:choose> | |
780 <xsl:when test="@units = 'other' and @otherunits"> | |
781 <xsl:value-of select="@otherunits"/> | |
782 </xsl:when> | |
783 <xsl:when test="@units"> | |
784 <xsl:value-of select="@units"/> | |
785 </xsl:when> | |
786 <!-- areaspec|areaset/area --> | |
787 <xsl:when test="../@units = 'other' and ../@otherunits"> | |
788 <xsl:value-of select="../@otherunits"/> | |
789 </xsl:when> | |
790 <xsl:when test="../@units"> | |
791 <xsl:value-of select="../@units"/> | |
792 </xsl:when> | |
793 <!-- areaspec/areaset/area --> | |
794 <xsl:when test="../../@units = 'other' and ../../@otherunits"> | |
795 <xsl:value-of select="../@otherunits"/> | |
796 </xsl:when> | |
797 <xsl:when test="../../@units"> | |
798 <xsl:value-of select="../../@units"/> | |
799 </xsl:when> | |
800 <xsl:otherwise>calspair</xsl:otherwise> | |
801 </xsl:choose> | |
802 </xsl:variable> | |
803 | |
804 <xsl:choose> | |
805 <xsl:when test="$units = 'calspair' or | |
806 $units = 'imagemap'"> | |
807 <xsl:variable name="coords" select="normalize-space(@coords)"/> | |
808 | |
809 <area shape="rect"> | |
810 <xsl:variable name="linkends"> | |
811 <xsl:choose> | |
812 <xsl:when test="@linkends"> | |
813 <xsl:value-of select="normalize-space(@linkends)"/> | |
814 </xsl:when> | |
815 <xsl:otherwise> | |
816 <xsl:value-of select="normalize-space(../@linkends)"/> | |
817 </xsl:otherwise> | |
818 </xsl:choose> | |
819 </xsl:variable> | |
820 | |
821 <xsl:variable name="href"> | |
822 <xsl:choose> | |
823 <xsl:when test="@xlink:href"> | |
824 <xsl:value-of select="@xlink:href"/> | |
825 </xsl:when> | |
826 <xsl:otherwise> | |
827 <xsl:value-of select="../@xlink:href"/> | |
828 </xsl:otherwise> | |
829 </xsl:choose> | |
830 </xsl:variable> | |
831 | |
832 <xsl:choose> | |
833 <xsl:when test="$linkends != ''"> | |
834 <xsl:variable name="linkend"> | |
835 <xsl:choose> | |
836 <xsl:when test="contains($linkends, ' ')"> | |
837 <xsl:value-of select="substring-before($linkends, ' ')"/
> | |
838 </xsl:when> | |
839 <xsl:otherwise> | |
840 <xsl:value-of select="$linkends"/> | |
841 </xsl:otherwise> | |
842 </xsl:choose> | |
843 </xsl:variable> | |
844 | |
845 <xsl:variable name="target" select="key('id', $linkend)[1]"/> | |
846 | |
847 <xsl:if test="$target"> | |
848 <xsl:attribute name="href"> | |
849 <xsl:call-template name="href.target"> | |
850 <xsl:with-param name="object" select="$target"/> | |
851 </xsl:call-template> | |
852 </xsl:attribute> | |
853 </xsl:if> | |
854 </xsl:when> | |
855 <xsl:when test="$href != ''"> | |
856 <xsl:attribute name="href"> | |
857 <xsl:value-of select="$href"/> | |
858 </xsl:attribute> | |
859 </xsl:when> | |
860 </xsl:choose> | |
861 | |
862 <xsl:if test="alt"> | |
863 <xsl:attribute name="alt"> | |
864 <xsl:value-of select="alt[1]"/> | |
865 </xsl:attribute> | |
866 </xsl:if> | |
867 | |
868 <xsl:attribute name="coords"> | |
869 <xsl:choose> | |
870 <xsl:when test="$units = 'calspair'"> | |
871 | |
872 <xsl:variable name="p1" | |
873 select="substring-before($coords, ' ')"/> | |
874 <xsl:variable name="p2" | |
875 select="substring-after($coords, ' ')"/> | |
876 | |
877 <xsl:variable name="x1" select="substring-before($p1,',')"/> | |
878 <xsl:variable name="y1" select="substring-after($p1,',')"/> | |
879 <xsl:variable name="x2" select="substring-before($p2,',')"/> | |
880 <xsl:variable name="y2" select="substring-after($p2,',')"/> | |
881 | |
882 <xsl:variable name="x1p" select="$x1 div 100.0"/> | |
883 <xsl:variable name="y1p" select="$y1 div 100.0"/> | |
884 <xsl:variable name="x2p" select="$x2 div 100.0"/> | |
885 <xsl:variable name="y2p" select="$y2 div 100.0"/> | |
886 | |
887 <!-- | |
888 <xsl:message> | |
889 <xsl:text>units: </xsl:text> | |
890 <xsl:value-of select="$units"/> | |
891 <xsl:text> </xsl:text> | |
892 <xsl:value-of select="$x1p"/><xsl:text>, </xsl:text> | |
893 <xsl:value-of select="$y1p"/><xsl:text>, </xsl:text> | |
894 <xsl:value-of select="$x2p"/><xsl:text>, </xsl:text> | |
895 <xsl:value-of select="$y2p"/><xsl:text>, </xsl:text> | |
896 </xsl:message> | |
897 | |
898 <xsl:message> | |
899 <xsl:text> </xsl:text> | |
900 <xsl:value-of select="$intrinsicwidth"/> | |
901 <xsl:text>, </xsl:text> | |
902 <xsl:value-of select="$intrinsicdepth"/> | |
903 </xsl:message> | |
904 | |
905 <xsl:message> | |
906 <xsl:text> </xsl:text> | |
907 <xsl:value-of select="$units"/> | |
908 <xsl:text> </xsl:text> | |
909 <xsl:value-of | |
910 select="round($x1p * $intrinsicwidth div 100.0)"/> | |
911 <xsl:text>,</xsl:text> | |
912 <xsl:value-of select="round($intrinsicdepth | |
913 - ($y2p * $intrinsicdepth div 100.0))"/> | |
914 <xsl:text>,</xsl:text> | |
915 <xsl:value-of select="round($x2p * | |
916 $intrinsicwidth div 100.0)"/> | |
917 <xsl:text>,</xsl:text> | |
918 <xsl:value-of select="round($intrinsicdepth | |
919 - ($y1p * $intrinsicdepth div 100.0))"/> | |
920 </xsl:message> | |
921 --> | |
922 <xsl:value-of | |
923 select="round($x1p * $intrinsicwidth div 100.0)"/> | |
924 <xsl:text>,</xsl:text> | |
925 <xsl:value-of select="round($intrinsicdepth | |
926 - ($y2p * $intrinsicdepth div 100.0))"/> | |
927 <xsl:text>,</xsl:text> | |
928 <xsl:value-of | |
929 select="round($x2p * $intrinsicwidth div 100.0)"/> | |
930 <xsl:text>,</xsl:text> | |
931 <xsl:value-of select="round($intrinsicdepth | |
932 - ($y1p * $intrinsicdepth div 100.0))"/> | |
933 </xsl:when> | |
934 <xsl:otherwise> | |
935 <xsl:copy-of select="$coords"/> | |
936 </xsl:otherwise> | |
937 </xsl:choose> | |
938 </xsl:attribute> | |
939 </area> | |
940 </xsl:when> | |
941 <xsl:otherwise> | |
942 <xsl:message> | |
943 <xsl:text>Warning: only calspair or </xsl:text> | |
944 <xsl:text>otherunits='imagemap' supported </xsl:text> | |
945 <xsl:text>in imageobjectco</xsl:text> | |
946 </xsl:message> | |
947 </xsl:otherwise> | |
948 </xsl:choose> | |
949 </xsl:for-each> | |
950 </map> | |
951 </xsl:if> | |
952 </xsl:template> | |
953 | |
954 <xsl:template name="process.image.attributes"> | |
955 <xsl:param name="alt"/> | |
956 <xsl:param name="html.width"/> | |
957 <xsl:param name="html.depth"/> | |
958 <xsl:param name="longdesc"/> | |
959 <xsl:param name="scale"/> | |
960 <xsl:param name="scalefit"/> | |
961 <xsl:param name="scaled.contentdepth"/> | |
962 <xsl:param name="scaled.contentwidth"/> | |
963 <xsl:param name="viewport"/> | |
964 | |
965 <xsl:choose> | |
966 <xsl:when test="@contentwidth or @contentdepth"> | |
967 <!-- ignore @width/@depth, @scale, and @scalefit if specified --> | |
968 <xsl:if test="@contentwidth and $scaled.contentwidth != ''"> | |
969 <xsl:attribute name="width"> | |
970 <xsl:value-of select="$scaled.contentwidth"/> | |
971 </xsl:attribute> | |
972 </xsl:if> | |
973 <xsl:if test="@contentdepth and $scaled.contentdepth != ''"> | |
974 <xsl:attribute name="height"> | |
975 <xsl:value-of select="$scaled.contentdepth"/> | |
976 </xsl:attribute> | |
977 </xsl:if> | |
978 </xsl:when> | |
979 | |
980 <xsl:when test="number($scale) != 1.0"> | |
981 <!-- scaling is always uniform, so we only have to specify one dimension -
-> | |
982 <!-- ignore @scalefit if specified --> | |
983 <xsl:attribute name="width"> | |
984 <xsl:value-of select="$scaled.contentwidth"/> | |
985 </xsl:attribute> | |
986 </xsl:when> | |
987 | |
988 <xsl:when test="$scalefit != 0"> | |
989 <xsl:choose> | |
990 <xsl:when test="contains($html.width, '%')"> | |
991 <xsl:choose> | |
992 <xsl:when test="$viewport != 0"> | |
993 <!-- The *viewport* will be scaled, so use 100% here! --> | |
994 <xsl:attribute name="width"> | |
995 <xsl:value-of select="'100%'"/> | |
996 </xsl:attribute> | |
997 </xsl:when> | |
998 <xsl:otherwise> | |
999 <xsl:attribute name="width"> | |
1000 <xsl:value-of select="$html.width"/> | |
1001 </xsl:attribute> | |
1002 </xsl:otherwise> | |
1003 </xsl:choose> | |
1004 </xsl:when> | |
1005 | |
1006 <xsl:when test="contains($html.depth, '%')"> | |
1007 <!-- HTML doesn't deal with this case very well...do nothing --> | |
1008 </xsl:when> | |
1009 | |
1010 <xsl:when test="$scaled.contentwidth != '' and $html.width != '' | |
1011 and $scaled.contentdepth != '' and $html.depth != ''"> | |
1012 <!-- scalefit should not be anamorphic; figure out which direction --> | |
1013 <!-- has the limiting scale factor and scale in that direction --> | |
1014 <xsl:choose> | |
1015 <xsl:when test="$html.width div $scaled.contentwidth > | |
1016 $html.depth div $scaled.contentdepth"> | |
1017 <xsl:attribute name="height"> | |
1018 <xsl:value-of select="$html.depth"/> | |
1019 </xsl:attribute> | |
1020 </xsl:when> | |
1021 <xsl:otherwise> | |
1022 <xsl:attribute name="width"> | |
1023 <xsl:value-of select="$html.width"/> | |
1024 </xsl:attribute> | |
1025 </xsl:otherwise> | |
1026 </xsl:choose> | |
1027 </xsl:when> | |
1028 | |
1029 <xsl:when test="$scaled.contentwidth != '' and $html.width != ''"> | |
1030 <xsl:attribute name="width"> | |
1031 <xsl:value-of select="$html.width"/> | |
1032 </xsl:attribute> | |
1033 </xsl:when> | |
1034 | |
1035 <xsl:when test="$scaled.contentdepth != '' and $html.depth != ''"> | |
1036 <xsl:attribute name="height"> | |
1037 <xsl:value-of select="$html.depth"/> | |
1038 </xsl:attribute> | |
1039 </xsl:when> | |
1040 </xsl:choose> | |
1041 </xsl:when> | |
1042 </xsl:choose> | |
1043 | |
1044 <xsl:if test="$alt != ''"> | |
1045 <xsl:attribute name="alt"> | |
1046 <xsl:value-of select="normalize-space($alt)"/> | |
1047 </xsl:attribute> | |
1048 </xsl:if> | |
1049 | |
1050 <!-- Turn off longdesc attribute since not supported by browsers | |
1051 <xsl:if test="$longdesc != ''"> | |
1052 <xsl:attribute name="longdesc"> | |
1053 <xsl:value-of select="$longdesc"/> | |
1054 </xsl:attribute> | |
1055 </xsl:if> | |
1056 --> | |
1057 | |
1058 <xsl:if test="@align and $viewport = 0"> | |
1059 <xsl:attribute name="align"> | |
1060 <xsl:choose> | |
1061 <xsl:when test="@align = 'center'">middle</xsl:when> | |
1062 <xsl:otherwise> | |
1063 <xsl:value-of select="@align"/> | |
1064 </xsl:otherwise> | |
1065 </xsl:choose> | |
1066 </xsl:attribute> | |
1067 </xsl:if> | |
1068 | |
1069 <xsl:call-template name="extension.process.image.attributes"/> | |
1070 </xsl:template> | |
1071 | |
1072 <xsl:template name="extension.process.image.attributes"/> | |
1073 | |
1074 <!-- ==================================================================== --> | |
1075 | |
1076 <xsl:template match="graphic"> | |
1077 <xsl:choose> | |
1078 <xsl:when test="parent::inlineequation"> | |
1079 <span> | |
1080 <xsl:call-template name="id.attribute"/> | |
1081 <xsl:call-template name="anchor"/> | |
1082 <xsl:call-template name="process.image"/> | |
1083 </span> | |
1084 </xsl:when> | |
1085 <xsl:otherwise> | |
1086 <div> | |
1087 <xsl:call-template name="id.attribute"/> | |
1088 <xsl:if test="@align"> | |
1089 <xsl:attribute name="align"> | |
1090 <xsl:value-of select="@align"/> | |
1091 </xsl:attribute> | |
1092 </xsl:if> | |
1093 <xsl:call-template name="anchor"/> | |
1094 <xsl:call-template name="process.image"/> | |
1095 </div> | |
1096 </xsl:otherwise> | |
1097 </xsl:choose> | |
1098 </xsl:template> | |
1099 | |
1100 <xsl:template match="inlinegraphic"> | |
1101 <xsl:variable name="filename"> | |
1102 <xsl:choose> | |
1103 <xsl:when test="@entityref"> | |
1104 <xsl:value-of select="unparsed-entity-uri(@entityref)"/> | |
1105 </xsl:when> | |
1106 <xsl:otherwise> | |
1107 <xsl:apply-templates select="@fileref"/> | |
1108 </xsl:otherwise> | |
1109 </xsl:choose> | |
1110 </xsl:variable> | |
1111 | |
1112 <xsl:call-template name="anchor"/> | |
1113 | |
1114 <xsl:choose> | |
1115 <xsl:when test="@format='linespecific'"> | |
1116 <xsl:choose> | |
1117 <xsl:when test="$use.extensions != '0' | |
1118 and $textinsert.extension != '0'"> | |
1119 <xsl:choose> | |
1120 <xsl:when test="element-available('stext:insertfile')"> | |
1121 <stext:insertfile href="{$filename}" encoding="{$textdata.default.
encoding}"/> | |
1122 </xsl:when> | |
1123 <xsl:when test="element-available('xtext:insertfile')"> | |
1124 <xtext:insertfile href="{$filename}"/> | |
1125 </xsl:when> | |
1126 <xsl:otherwise> | |
1127 <xsl:message terminate="yes"> | |
1128 <xsl:text>No insertfile extension available.</xsl:text> | |
1129 </xsl:message> | |
1130 </xsl:otherwise> | |
1131 </xsl:choose> | |
1132 </xsl:when> | |
1133 <xsl:otherwise> | |
1134 <xsl:message terminate="yes"> | |
1135 <xsl:text>Cannot insert </xsl:text><xsl:value-of select="$filename"/
> | |
1136 <xsl:text>. Check use.extensions and textinsert.extension parameters
.</xsl:text> | |
1137 </xsl:message> | |
1138 </xsl:otherwise> | |
1139 </xsl:choose> | |
1140 </xsl:when> | |
1141 <xsl:otherwise> | |
1142 <xsl:call-template name="process.image"/> | |
1143 </xsl:otherwise> | |
1144 </xsl:choose> | |
1145 </xsl:template> | |
1146 | |
1147 <!-- ==================================================================== --> | |
1148 | |
1149 <xsl:template match="mediaobject|mediaobjectco"> | |
1150 | |
1151 <xsl:variable name="olist" select="imageobject|imageobjectco | |
1152 |videoobject|audioobject | |
1153 |textobject"/> | |
1154 | |
1155 <xsl:variable name="object.index"> | |
1156 <xsl:call-template name="select.mediaobject.index"> | |
1157 <xsl:with-param name="olist" select="$olist"/> | |
1158 <xsl:with-param name="count" select="1"/> | |
1159 </xsl:call-template> | |
1160 </xsl:variable> | |
1161 | |
1162 <xsl:variable name="object" select="$olist[position() = $object.index]"/> | |
1163 | |
1164 <xsl:variable name="align"> | |
1165 <xsl:value-of select="$object/descendant::imagedata[@align][1]/@align"/> | |
1166 </xsl:variable> | |
1167 | |
1168 <div> | |
1169 <xsl:apply-templates select="." mode="common.html.attributes"/> | |
1170 <xsl:if test="$align != '' "> | |
1171 <xsl:attribute name="align"> | |
1172 <xsl:value-of select="$align"/> | |
1173 </xsl:attribute> | |
1174 </xsl:if> | |
1175 <xsl:call-template name="id.attribute"/> | |
1176 <xsl:call-template name="anchor"/> | |
1177 | |
1178 <xsl:apply-templates select="$object"/> | |
1179 <xsl:apply-templates select="caption"/> | |
1180 </div> | |
1181 </xsl:template> | |
1182 | |
1183 <xsl:template match="inlinemediaobject"> | |
1184 <span> | |
1185 <xsl:apply-templates select="." mode="common.html.attributes"/> | |
1186 <xsl:call-template name="id.attribute"/> | |
1187 <xsl:call-template name="anchor"/> | |
1188 <xsl:call-template name="select.mediaobject"/> | |
1189 </span> | |
1190 </xsl:template> | |
1191 | |
1192 <xsl:template match="programlisting/inlinemediaobject | |
1193 |screen/inlinemediaobject" priority="2"> | |
1194 <!-- the additional span causes problems in some cases --> | |
1195 <xsl:call-template name="select.mediaobject"/> | |
1196 </xsl:template> | |
1197 | |
1198 <!-- ==================================================================== --> | |
1199 | |
1200 <xsl:template match="imageobjectco"> | |
1201 <xsl:call-template name="anchor"/> | |
1202 <xsl:choose> | |
1203 <!-- select one imageobject? --> | |
1204 <xsl:when test="$use.role.for.mediaobject != 0 and | |
1205 count(imageobject) > 1 and | |
1206 imageobject[@role]"> | |
1207 <xsl:variable name="olist" select="imageobject"/> | |
1208 | |
1209 <xsl:variable name="object.index"> | |
1210 <xsl:call-template name="select.mediaobject.index"> | |
1211 <xsl:with-param name="olist" select="$olist"/> | |
1212 <xsl:with-param name="count" select="1"/> | |
1213 </xsl:call-template> | |
1214 </xsl:variable> | |
1215 | |
1216 <xsl:variable name="object" select="$olist[position() = $object.index]"/> | |
1217 | |
1218 <xsl:apply-templates select="$object"/> | |
1219 </xsl:when> | |
1220 <xsl:otherwise> | |
1221 <!-- otherwise process them all --> | |
1222 <xsl:apply-templates select="imageobject"/> | |
1223 </xsl:otherwise> | |
1224 </xsl:choose> | |
1225 | |
1226 <xsl:apply-templates select="calloutlist"/> | |
1227 | |
1228 </xsl:template> | |
1229 | |
1230 <xsl:template match="imageobject"> | |
1231 <xsl:apply-templates select="imagedata"/> | |
1232 </xsl:template> | |
1233 | |
1234 <xsl:template match="imagedata"> | |
1235 <xsl:variable name="filename"> | |
1236 <xsl:call-template name="mediaobject.filename"> | |
1237 <xsl:with-param name="object" select=".."/> | |
1238 </xsl:call-template> | |
1239 </xsl:variable> | |
1240 | |
1241 <xsl:choose> | |
1242 <!-- Handle MathML and SVG markup in imagedata --> | |
1243 <xsl:when test="mml:*" xmlns:mml="http://www.w3.org/1998/Math/MathML"> | |
1244 <xsl:apply-templates/> | |
1245 </xsl:when> | |
1246 | |
1247 <xsl:when test="svg:*" xmlns:svg="http://www.w3.org/2000/svg"> | |
1248 <xsl:apply-templates/> | |
1249 </xsl:when> | |
1250 | |
1251 <xsl:when test="@format='linespecific'"> | |
1252 <xsl:choose> | |
1253 <xsl:when test="$use.extensions != '0' | |
1254 and $textinsert.extension != '0'"> | |
1255 <xsl:choose> | |
1256 <xsl:when test="element-available('stext:insertfile')"> | |
1257 <stext:insertfile href="{$filename}" encoding="{$textdata.default.
encoding}"/> | |
1258 </xsl:when> | |
1259 <xsl:when test="element-available('xtext:insertfile')"> | |
1260 <xtext:insertfile href="{$filename}"/> | |
1261 </xsl:when> | |
1262 <xsl:otherwise> | |
1263 <xsl:message terminate="yes"> | |
1264 <xsl:text>No insertfile extension available.</xsl:text> | |
1265 </xsl:message> | |
1266 </xsl:otherwise> | |
1267 </xsl:choose> | |
1268 </xsl:when> | |
1269 <xsl:otherwise> | |
1270 <a xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" | |
1271 href="{$filename}"/> | |
1272 </xsl:otherwise> | |
1273 </xsl:choose> | |
1274 </xsl:when> | |
1275 <xsl:otherwise> | |
1276 <xsl:variable name="longdesc.uri"> | |
1277 <xsl:call-template name="longdesc.uri"> | |
1278 <xsl:with-param name="mediaobject" | |
1279 select="ancestor::imageobject/parent::*"/> | |
1280 </xsl:call-template> | |
1281 </xsl:variable> | |
1282 | |
1283 <xsl:variable name="phrases" | |
1284 select="ancestor::mediaobject/textobject[phrase] | |
1285 |ancestor::inlinemediaobject/textobject[phrase] | |
1286 |ancestor::mediaobjectco/textobject[phrase]"/> | |
1287 | |
1288 <xsl:call-template name="process.image"> | |
1289 <xsl:with-param name="alt"> | |
1290 <xsl:choose> | |
1291 <xsl:when test="ancestor::mediaobject/alt"> | |
1292 <xsl:apply-templates select="ancestor::mediaobject/alt"/> | |
1293 </xsl:when> | |
1294 <xsl:otherwise> | |
1295 <xsl:apply-templates select="$phrases[not(@role) or @role!='tex'][
1]"/> | |
1296 </xsl:otherwise> | |
1297 </xsl:choose> | |
1298 </xsl:with-param> | |
1299 <xsl:with-param name="longdesc"> | |
1300 <xsl:call-template name="write.longdesc"> | |
1301 <xsl:with-param name="mediaobject" | |
1302 select="ancestor::imageobject/parent::*"/> | |
1303 </xsl:call-template> | |
1304 </xsl:with-param> | |
1305 </xsl:call-template> | |
1306 | |
1307 <xsl:if test="$html.longdesc != 0 and $html.longdesc.link != 0 | |
1308 and ancestor::imageobject/parent::*/textobject[not(phrase)]"
> | |
1309 <xsl:call-template name="longdesc.link"> | |
1310 <xsl:with-param name="longdesc.uri" select="$longdesc.uri"/> | |
1311 </xsl:call-template> | |
1312 </xsl:if> | |
1313 </xsl:otherwise> | |
1314 </xsl:choose> | |
1315 </xsl:template> | |
1316 | |
1317 <!-- ==================================================================== --> | |
1318 | |
1319 <xsl:template name="longdesc.uri"> | |
1320 <xsl:param name="mediaobject" select="."/> | |
1321 <xsl:if test="$html.longdesc"> | |
1322 <xsl:if test="$mediaobject/textobject[not(phrase)]"> | |
1323 <xsl:variable name="dbhtml.dir"> | |
1324 <xsl:call-template name="dbhtml-dir"/> | |
1325 </xsl:variable> | |
1326 <xsl:variable name="filename"> | |
1327 <xsl:call-template name="make-relative-filename"> | |
1328 <xsl:with-param name="base.dir"> | |
1329 <xsl:choose> | |
1330 <xsl:when test="$dbhtml.dir != ''"> | |
1331 <xsl:value-of select="$dbhtml.dir"/> | |
1332 </xsl:when> | |
1333 <xsl:otherwise> | |
1334 <xsl:value-of select="$chunk.base.dir"/> | |
1335 </xsl:otherwise> | |
1336 </xsl:choose> | |
1337 </xsl:with-param> | |
1338 <xsl:with-param name="base.name"> | |
1339 <xsl:choose> | |
1340 <xsl:when test=" | |
1341 $mediaobject/@*[local-name() = 'id'] | |
1342 and not($use.id.as.filename = 0)"> | |
1343 <!-- * if this mediaobject has an ID, then we use the --> | |
1344 <!-- * value of that ID as basename for the "longdesc" --> | |
1345 <!-- * file (that is, without prepending an "ld-" too it) --> | |
1346 <xsl:value-of select="$mediaobject/@*[local-name() = 'id']"/> | |
1347 <xsl:value-of select="$html.ext"/> | |
1348 </xsl:when> | |
1349 <xsl:otherwise> | |
1350 <!-- * otherwise, if this mediaobject does not have an --> | |
1351 <!-- * ID, then we generate an ID... --> | |
1352 <xsl:variable name="image-id"> | |
1353 <xsl:call-template name="object.id"> | |
1354 <xsl:with-param name="object" select="$mediaobject"/> | |
1355 </xsl:call-template> | |
1356 </xsl:variable> | |
1357 <!-- * ...and then we take that generated ID, prepend an --> | |
1358 <!-- * "ld-" to it, and use that as the basename for the file --
> | |
1359 <xsl:value-of select="concat('ld-',$image-id,$html.ext)"/> | |
1360 </xsl:otherwise> | |
1361 </xsl:choose> | |
1362 </xsl:with-param> | |
1363 </xsl:call-template> | |
1364 </xsl:variable> | |
1365 | |
1366 <xsl:value-of select="$filename"/> | |
1367 </xsl:if> | |
1368 </xsl:if> | |
1369 </xsl:template> | |
1370 | |
1371 <xsl:template name="write.longdesc"> | |
1372 <xsl:param name="mediaobject" select="."/> | |
1373 <xsl:if test="$html.longdesc != 0 and $mediaobject/textobject[not(phrase)]"> | |
1374 <xsl:variable name="filename"> | |
1375 <xsl:call-template name="longdesc.uri"> | |
1376 <xsl:with-param name="mediaobject" select="$mediaobject"/> | |
1377 </xsl:call-template> | |
1378 </xsl:variable> | |
1379 | |
1380 <xsl:value-of select="$filename"/> | |
1381 | |
1382 <xsl:call-template name="write.chunk"> | |
1383 <xsl:with-param name="filename" select="$filename"/> | |
1384 <xsl:with-param name="quiet" select="$chunk.quietly"/> | |
1385 <xsl:with-param name="content"> | |
1386 <xsl:call-template name="user.preroot"/> | |
1387 <html> | |
1388 <head> | |
1389 <xsl:call-template name="system.head.content"/> | |
1390 <xsl:call-template name="head.content"> | |
1391 <xsl:with-param name="title" select="'Long Description'"/> | |
1392 </xsl:call-template> | |
1393 <xsl:call-template name="user.head.content"/> | |
1394 </head> | |
1395 <body> | |
1396 <xsl:call-template name="body.attributes"/> | |
1397 <xsl:for-each select="$mediaobject/textobject[not(phrase)]"> | |
1398 <xsl:apply-templates select="./*"/> | |
1399 </xsl:for-each> | |
1400 </body> | |
1401 </html> | |
1402 <xsl:value-of select="$chunk.append"/> | |
1403 </xsl:with-param> | |
1404 </xsl:call-template> | |
1405 </xsl:if> | |
1406 </xsl:template> | |
1407 | |
1408 <xsl:template name="longdesc.link"> | |
1409 <xsl:param name="longdesc.uri" select="''"/> | |
1410 | |
1411 <xsl:variable name="this.uri"> | |
1412 <xsl:call-template name="make-relative-filename"> | |
1413 <xsl:with-param name="base.dir" select="$chunk.base.dir"/> | |
1414 <xsl:with-param name="base.name"> | |
1415 <xsl:call-template name="href.target.uri"/> | |
1416 </xsl:with-param> | |
1417 </xsl:call-template> | |
1418 </xsl:variable> | |
1419 | |
1420 <xsl:variable name="href.to"> | |
1421 <xsl:call-template name="trim.common.uri.paths"> | |
1422 <xsl:with-param name="uriA" select="$longdesc.uri"/> | |
1423 <xsl:with-param name="uriB" select="$this.uri"/> | |
1424 <xsl:with-param name="return" select="'A'"/> | |
1425 </xsl:call-template> | |
1426 </xsl:variable> | |
1427 | |
1428 <div class="longdesc-link" align="{$direction.align.end}"> | |
1429 <br clear="all"/> | |
1430 <span class="longdesc-link"> | |
1431 <xsl:text>[</xsl:text> | |
1432 <a href="{$href.to}" target="longdesc">D</a> | |
1433 <xsl:text>]</xsl:text> | |
1434 </span> | |
1435 </div> | |
1436 </xsl:template> | |
1437 | |
1438 <!-- ==================================================================== --> | |
1439 | |
1440 <xsl:template match="mediaobject/alt"> | |
1441 <xsl:apply-templates/> | |
1442 </xsl:template> | |
1443 | |
1444 <xsl:template match="videoobject"> | |
1445 <xsl:apply-templates select="videodata"/> | |
1446 </xsl:template> | |
1447 | |
1448 <xsl:template match="videodata"> | |
1449 <xsl:call-template name="process.image"> | |
1450 <xsl:with-param name="tag" select="'embed'"/> | |
1451 <xsl:with-param name="alt"> | |
1452 <xsl:choose> | |
1453 <xsl:when test="ancestor::mediaobject/alt"> | |
1454 <xsl:apply-templates select="ancestor::mediaobject/alt"/> | |
1455 </xsl:when> | |
1456 <xsl:otherwise> | |
1457 <xsl:apply-templates select="(ancestor::mediaobject/textobject/phrase)
[1]"/> | |
1458 </xsl:otherwise> | |
1459 </xsl:choose> | |
1460 </xsl:with-param> | |
1461 </xsl:call-template> | |
1462 </xsl:template> | |
1463 | |
1464 <!-- ==================================================================== --> | |
1465 | |
1466 <xsl:template match="audioobject"> | |
1467 <xsl:apply-templates select="audiodata"/> | |
1468 </xsl:template> | |
1469 | |
1470 <xsl:template match="audiodata"> | |
1471 <xsl:call-template name="process.image"> | |
1472 <xsl:with-param name="tag" select="'embed'"/> | |
1473 <xsl:with-param name="alt"> | |
1474 <xsl:choose> | |
1475 <xsl:when test="ancestor::mediaobject/alt"> | |
1476 <xsl:apply-templates select="ancestor::mediaobject/alt"/> | |
1477 </xsl:when> | |
1478 <xsl:otherwise> | |
1479 <xsl:apply-templates select="(ancestor::mediaobject/textobject/phrase)
[1]"/> | |
1480 </xsl:otherwise> | |
1481 </xsl:choose> | |
1482 </xsl:with-param> | |
1483 </xsl:call-template> | |
1484 </xsl:template> | |
1485 | |
1486 <!-- ==================================================================== --> | |
1487 | |
1488 <xsl:template match="textobject"> | |
1489 <xsl:apply-templates/> | |
1490 </xsl:template> | |
1491 | |
1492 <xsl:template match="textdata"> | |
1493 <xsl:variable name="filename"> | |
1494 <xsl:choose> | |
1495 <xsl:when test="@entityref"> | |
1496 <xsl:value-of select="unparsed-entity-uri(@entityref)"/> | |
1497 </xsl:when> | |
1498 <xsl:otherwise> | |
1499 <xsl:apply-templates select="@fileref"/> | |
1500 </xsl:otherwise> | |
1501 </xsl:choose> | |
1502 </xsl:variable> | |
1503 | |
1504 <xsl:variable name="encoding"> | |
1505 <xsl:choose> | |
1506 <xsl:when test="@encoding"> | |
1507 <xsl:value-of select="@encoding"/> | |
1508 </xsl:when> | |
1509 <xsl:otherwise> | |
1510 <xsl:value-of select="$textdata.default.encoding"/> | |
1511 </xsl:otherwise> | |
1512 </xsl:choose> | |
1513 </xsl:variable> | |
1514 | |
1515 <xsl:choose> | |
1516 <xsl:when test="$use.extensions != '0' | |
1517 and $textinsert.extension != '0'"> | |
1518 <xsl:choose> | |
1519 <xsl:when test="element-available('stext:insertfile')"> | |
1520 <stext:insertfile href="{$filename}" encoding="{$encoding}"/> | |
1521 </xsl:when> | |
1522 <xsl:when test="element-available('xtext:insertfile')"> | |
1523 <xtext:insertfile href="{$filename}"/> | |
1524 </xsl:when> | |
1525 <xsl:otherwise> | |
1526 <xsl:message terminate="yes"> | |
1527 <xsl:text>No insertfile extension available.</xsl:text> | |
1528 </xsl:message> | |
1529 </xsl:otherwise> | |
1530 </xsl:choose> | |
1531 </xsl:when> | |
1532 <xsl:otherwise> | |
1533 <xsl:message terminate="yes"> | |
1534 <xsl:text>Cannot insert </xsl:text><xsl:value-of select="$filename"/> | |
1535 <xsl:text>. Check use.extensions and textinsert.extension parameters.</x
sl:text> | |
1536 </xsl:message> | |
1537 </xsl:otherwise> | |
1538 </xsl:choose> | |
1539 </xsl:template> | |
1540 | |
1541 <!-- ==================================================================== --> | |
1542 | |
1543 <xsl:template match="caption"> | |
1544 <div> | |
1545 <xsl:apply-templates select="." mode="common.html.attributes"/> | |
1546 <xsl:call-template name="id.attribute"/> | |
1547 <xsl:if test="@align = 'right' or @align = 'left' or @align='center'"> | |
1548 <xsl:attribute name="align"><xsl:value-of | |
1549 select="@align"/></xsl:attribute> | |
1550 </xsl:if> | |
1551 <xsl:apply-templates/> | |
1552 </div> | |
1553 </xsl:template> | |
1554 | |
1555 <!-- ==================================================================== --> | |
1556 <!-- "Support" for SVG --> | |
1557 | |
1558 <xsl:template match="svg:*" xmlns:svg="http://www.w3.org/2000/svg"> | |
1559 <xsl:copy> | |
1560 <xsl:copy-of select="@*"/> | |
1561 <xsl:apply-templates/> | |
1562 </xsl:copy> | |
1563 </xsl:template> | |
1564 | |
1565 | |
1566 <!-- The following works sometimes, but needs to take into account | |
1567 1. When there is no /*/@xml:base | |
1568 2. When the chunks are going somewhere else | |
1569 <xsl:variable name="relpath"> | |
1570 <xsl:call-template name="relative-uri"> | |
1571 <xsl:with-param name="filename" select="@fileref"/> | |
1572 </xsl:call-template> | |
1573 </xsl:variable> | |
1574 | |
1575 <xsl:choose> | |
1576 <xsl:when test="/*/@xml:base | |
1577 and starts-with($relpath,/*/@xml:base)"> | |
1578 <xsl:value-of select="substring-after($relpath,/*/@xml:base)"/> | |
1579 </xsl:when> | |
1580 <xsl:otherwise> | |
1581 <xsl:value-of select="@fileref"/> | |
1582 </xsl:otherwise> | |
1583 </xsl:choose> | |
1584 <xsl:value-of select="@fileref"/> | |
1585 </xsl:when> | |
1586 --> | |
1587 <!-- Resolve xml:base attributes --> | |
1588 <xsl:template match="@fileref"> | |
1589 <!-- need a check for absolute urls --> | |
1590 <xsl:choose> | |
1591 <xsl:when test="contains(., ':')"> | |
1592 <!-- it has a uri scheme so it is an absolute uri --> | |
1593 <xsl:value-of select="."/> | |
1594 </xsl:when> | |
1595 <xsl:when test="$keep.relative.image.uris != 0"> | |
1596 <!-- leave it alone --> | |
1597 <xsl:value-of select="."/> | |
1598 </xsl:when> | |
1599 <xsl:otherwise> | |
1600 <!-- its a relative uri that needs xml:base processing --> | |
1601 <xsl:call-template name="relative-uri"> | |
1602 </xsl:call-template> | |
1603 </xsl:otherwise> | |
1604 </xsl:choose> | |
1605 </xsl:template> | |
1606 | |
1607 </xsl:stylesheet> | |
OLD | NEW |