source: trunk/Distribution/XSL/html/graphics.xsl@ 2

Last change on this file since 2 was 2, checked in by jkacer, 18 years ago

Added all DocBook Framework stuff:

  • DocBook DTD
  • Transformation software FOP 0.20.5 and Saxon 6
  • XSL styles
  • Rexx scripts

Also added some WarpIN-related stuff for creation of WarpIN installation packages.
This state corresponds to version 1.0.0 from November 2005, just slightly modified to carry versioning information (Rexx scripts).

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