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