source: stylesheets/lfs-xsl/docbook-xsl-1.78.1/xhtml-1_1/graphics.xsl@ c158fe6

7.5-systemd 7.6-systemd 7.7-systemd 7.8-systemd 7.9-systemd
Last change on this file since c158fe6 was b1a51ac1, checked in by Krejzi <krejzi@…>, 11 years ago

Import new branch

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/systemd/BOOK@10389 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

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