1 <?xml version="1.0" encoding="US-ASCII"?>
2 <!--This file was created automatically by html2xhtml-->
3 <!--from the HTML stylesheets. Do not edit this file.-->
4 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:stext="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.TextFactory" xmlns:simg="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.ImageIntrinsics" xmlns:ximg="xaln://com.nwalsh.xalan.ImageIntrinsics" xmlns:xtext="com.nwalsh.xalan.Text" xmlns:lxslt="http://xml.apache.org/xslt" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="xlink stext xtext lxslt simg ximg" extension-element-prefixes="stext xtext" version="1.0">
6 <!-- ********************************************************************
8 ********************************************************************
10 This file is part of the XSL DocBook Stylesheet distribution.
11 See ../README or http://nwalsh.com/docbook/xsl/ for copyright
12 and other information.
15 Colin Paul Adams, <colin@colina.demon.co.uk>
17 ******************************************************************** -->
19 <lxslt:component prefix="xtext" elements="insertfile"/>
20 <lxslt:component prefix="ximg" functions="new getWidth getDepth"/>
22 <!-- ==================================================================== -->
23 <!-- Graphic format tests for the HTML backend -->
25 <xsl:template name="is.graphic.format">
26 <xsl:param name="format"/>
27 <xsl:if test="$format = 'SVG' or $format = 'PNG' or $format = 'JPG' or $format = 'JPEG' or $format = 'linespecific' or $format = 'GIF' or $format = 'GIF87a' or $format = 'GIF89a' or $format = 'BMP'">1</xsl:if>
30 <xsl:template name="is.graphic.extension">
31 <xsl:param name="ext"/>
32 <xsl:variable name="lcext" select="translate($ext, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/>
33 <xsl:if test="$lcext = 'svg' or $lcext = 'png' or $lcext = 'jpeg' or $lcext = 'jpg' or $lcext = 'avi' or $lcext = 'mpg' or $lcext = 'mpeg' or $lcext = 'qt' or $lcext = 'gif' or $lcext = 'bmp'">1</xsl:if>
36 <!-- ==================================================================== -->
38 <xsl:template match="screenshot">
39 <div class="{name(.)}">
40 <xsl:apply-templates/>
44 <xsl:template match="screeninfo">
47 <!-- ==================================================================== -->
49 <xsl:template name="process.image">
50 <!-- When this template is called, the current node should be -->
51 <!-- a graphic, inlinegraphic, imagedata, or videodata. All -->
52 <!-- those elements have the same set of attributes, so we can -->
53 <!-- handle them all in one place. -->
54 <xsl:param name="tag" select="'img'"/>
55 <xsl:param name="alt"/>
56 <xsl:param name="longdesc"/>
58 <!-- The HTML img element only supports the notion of content-area
59 scaling; it doesn't support the distinction between a
60 content-area and a viewport-area, so we have to make some
63 1. If only the content-area is specified, everything is fine.
64 (If you ask for a three inch image, that's what you'll get.)
66 2. If only the viewport-area is provided:
67 - If scalefit=1, treat it as both the content-area and
68 the viewport-area. (If you ask for an image in a five inch
69 area, we'll make the image five inches to fill that area.)
70 - If scalefit=0, ignore the viewport-area specification.
72 Note: this is not quite the right semantic and has the additional
73 problem that it can result in anamorphic scaling, which scalefit
76 3. If both the content-area and the viewport-area is specified
77 on a graphic element, ignore the viewport-area.
78 (If you ask for a three inch image in a five inch area, we'll assume
79 it's better to give you a three inch image in an unspecified area
80 than a five inch image in a five inch area.
82 Relative units also cause problems. As a general rule, the stylesheets
83 are operating too early and too loosely coupled with the rendering engine
84 to know things like the current font size or the actual dimensions of
87 1. We use a fixed size for pixels, $pixels.per.inch
89 2. We use a fixed size for "em"s, $points.per.em
91 Percentages are problematic. In the following discussion, we speak
92 of width and contentwidth, but the same issues apply to depth and
95 1. A width of 50% means "half of the available space for the image."
96 That's fine. But note that in HTML, this is a dynamic property and
97 the image size will vary if the browser window is resized.
99 2. A contentwidth of 50% means "half of the actual image width". But
100 the stylesheets have no way to assess the image's actual size. Treating
101 this as a width of 50% is one possibility, but it produces behavior
102 (dynamic scaling) that seems entirely out of character with the
105 Instead, the stylesheets define a $nominal.image.width
106 and convert percentages to actual values based on that nominal size.
108 Scale can be problematic. Scale applies to the contentwidth, so
109 a scale of 50 when a contentwidth is not specified is analagous to a
110 width of 50%. (If a contentwidth is specified, the scaling factor can
111 be applied to that value and no problem exists.)
113 If scale is specified but contentwidth is not supplied, the
114 nominal.image.width is used to calculate a base size
117 Warning: as a consequence of these decisions, unless the aspect ratio
118 of your image happens to be exactly the same as (nominal width / nominal height),
119 specifying contentwidth="50%" and contentdepth="50%" is NOT going to
120 scale the way you expect (or really, the way it should).
122 Don't do that. In fact, a percentage value is not recommended for content
123 size at all. Use scale instead.
125 Finally, align and valign are troublesome. Horizontal alignment is now
126 supported by wrapping the image in a <div align="{@align}"> (in block
127 contexts!). I can't think of anything (practical) to do about vertical
131 <xsl:variable name="width-units">
133 <xsl:when test="$ignore.image.scaling != 0"/>
134 <xsl:when test="@width">
135 <xsl:call-template name="length-units">
136 <xsl:with-param name="length" select="@width"/>
139 <xsl:when test="not(@depth) and $default.image.width != ''">
140 <xsl:call-template name="length-units">
141 <xsl:with-param name="length" select="$default.image.width"/>
147 <xsl:variable name="width">
149 <xsl:when test="$ignore.image.scaling != 0"/>
150 <xsl:when test="@width">
152 <xsl:when test="$width-units = '%'">
153 <xsl:value-of select="@width"/>
156 <xsl:call-template name="length-spec">
157 <xsl:with-param name="length" select="@width"/>
162 <xsl:when test="not(@depth) and $default.image.width != ''">
163 <xsl:value-of select="$default.image.width"/>
168 <xsl:variable name="scalefit">
170 <xsl:when test="$ignore.image.scaling != 0">0</xsl:when>
171 <xsl:when test="@contentwidth or @contentdepth">0</xsl:when>
172 <xsl:when test="@scale">0</xsl:when>
173 <xsl:when test="@scalefit"><xsl:value-of select="@scalefit"/></xsl:when>
174 <xsl:when test="$width != '' or @depth">1</xsl:when>
175 <xsl:otherwise>0</xsl:otherwise>
179 <xsl:variable name="scale">
181 <xsl:when test="$ignore.image.scaling != 0">1.0</xsl:when>
182 <xsl:when test="@contentwidth or @contentdepth">1.0</xsl:when>
183 <xsl:when test="@scale">
184 <xsl:value-of select="@scale div 100.0"/>
186 <xsl:otherwise>1.0</xsl:otherwise>
190 <xsl:variable name="filename">
192 <xsl:when test="local-name(.) = 'graphic' or local-name(.) = 'inlinegraphic'">
193 <!-- handle legacy graphic and inlinegraphic by new template -->
194 <xsl:call-template name="mediaobject.filename">
195 <xsl:with-param name="object" select="."/>
199 <!-- imagedata, videodata, audiodata -->
200 <xsl:call-template name="mediaobject.filename">
201 <xsl:with-param name="object" select=".."/>
207 <xsl:variable name="img.src.path.pi">
208 <xsl:call-template name="dbhtml-attribute">
209 <xsl:with-param name="pis" select="../processing-instruction('dbhtml')"/>
210 <xsl:with-param name="attribute" select="'img.src.path'"/>
214 <xsl:variable name="filename.for.graphicsize">
216 <xsl:when test="$img.src.path.pi != ''">
217 <xsl:value-of select="concat($img.src.path.pi, $filename)"/>
219 <xsl:when test="$img.src.path != '' and $graphicsize.use.img.src.path != 0 and $tag = 'img' and not(starts-with($filename, '/')) and not(contains($filename, '://'))">
220 <xsl:value-of select="concat($img.src.path, $filename)"/>
223 <xsl:value-of select="$filename"/>
228 <xsl:variable name="realintrinsicwidth">
229 <!-- This funny compound test works around a bug in XSLTC -->
231 <xsl:when test="$use.extensions != 0 and $graphicsize.extension != 0">
233 <xsl:when test="function-available('simg:getWidth')">
234 <xsl:value-of select="simg:getWidth(simg:new($filename.for.graphicsize), $nominal.image.width)"/>
236 <xsl:when test="function-available('ximg:getWidth')">
237 <xsl:value-of select="ximg:getWidth(ximg:new($filename.for.graphicsize), $nominal.image.width)"/>
240 <xsl:value-of select="0"/>
245 <xsl:value-of select="0"/>
250 <xsl:variable name="intrinsicwidth">
252 <xsl:when test="$realintrinsicwidth = 0">
253 <xsl:value-of select="$nominal.image.width"/>
256 <xsl:value-of select="$realintrinsicwidth"/>
261 <xsl:variable name="intrinsicdepth">
262 <!-- This funny compound test works around a bug in XSLTC -->
264 <xsl:when test="$use.extensions != 0 and $graphicsize.extension != 0">
266 <xsl:when test="function-available('simg:getDepth')">
267 <xsl:value-of select="simg:getDepth(simg:new($filename.for.graphicsize), $nominal.image.depth)"/>
269 <xsl:when test="function-available('ximg:getDepth')">
270 <xsl:value-of select="ximg:getDepth(ximg:new($filename.for.graphicsize), $nominal.image.depth)"/>
273 <xsl:value-of select="$nominal.image.depth"/>
278 <xsl:value-of select="$nominal.image.depth"/>
283 <xsl:variable name="contentwidth">
285 <xsl:when test="$ignore.image.scaling != 0"/>
286 <xsl:when test="@contentwidth">
287 <xsl:variable name="units">
288 <xsl:call-template name="length-units">
289 <xsl:with-param name="length" select="@contentwidth"/>
294 <xsl:when test="$units = '%'">
295 <xsl:variable name="cmagnitude">
296 <xsl:call-template name="length-magnitude">
297 <xsl:with-param name="length" select="@contentwidth"/>
300 <xsl:value-of select="$intrinsicwidth * $cmagnitude div 100.0"/>
301 <xsl:text>px</xsl:text>
304 <xsl:call-template name="length-spec">
305 <xsl:with-param name="length" select="@contentwidth"/>
311 <xsl:value-of select="$intrinsicwidth"/>
312 <xsl:text>px</xsl:text>
317 <xsl:variable name="scaled.contentwidth">
318 <xsl:if test="$contentwidth != ''">
319 <xsl:variable name="cwidth.in.points">
320 <xsl:call-template name="length-in-points">
321 <xsl:with-param name="length" select="$contentwidth"/>
322 <xsl:with-param name="pixels.per.inch" select="$pixels.per.inch"/>
323 <xsl:with-param name="em.size" select="$points.per.em"/>
326 <xsl:value-of select="$cwidth.in.points div 72.0 * $pixels.per.inch * $scale"/>
330 <xsl:variable name="html.width">
332 <xsl:when test="$ignore.image.scaling != 0"/>
333 <xsl:when test="$width-units = '%'">
334 <xsl:value-of select="$width"/>
336 <xsl:when test="$width != ''">
337 <xsl:variable name="width.in.points">
338 <xsl:call-template name="length-in-points">
339 <xsl:with-param name="length" select="$width"/>
340 <xsl:with-param name="pixels.per.inch" select="$pixels.per.inch"/>
341 <xsl:with-param name="em.size" select="$points.per.em"/>
344 <xsl:value-of select="round($width.in.points div 72.0 * $pixels.per.inch)"/>
350 <xsl:variable name="contentdepth">
352 <xsl:when test="$ignore.image.scaling != 0"/>
353 <xsl:when test="@contentdepth">
354 <xsl:variable name="units">
355 <xsl:call-template name="length-units">
356 <xsl:with-param name="length" select="@contentdepth"/>
361 <xsl:when test="$units = '%'">
362 <xsl:variable name="cmagnitude">
363 <xsl:call-template name="length-magnitude">
364 <xsl:with-param name="length" select="@contentdepth"/>
367 <xsl:value-of select="$intrinsicdepth * $cmagnitude div 100.0"/>
368 <xsl:text>px</xsl:text>
371 <xsl:call-template name="length-spec">
372 <xsl:with-param name="length" select="@contentdepth"/>
378 <xsl:value-of select="$intrinsicdepth"/>
379 <xsl:text>px</xsl:text>
384 <xsl:variable name="scaled.contentdepth">
385 <xsl:if test="$contentdepth != ''">
386 <xsl:variable name="cdepth.in.points">
387 <xsl:call-template name="length-in-points">
388 <xsl:with-param name="length" select="$contentdepth"/>
389 <xsl:with-param name="pixels.per.inch" select="$pixels.per.inch"/>
390 <xsl:with-param name="em.size" select="$points.per.em"/>
393 <xsl:value-of select="$cdepth.in.points div 72.0 * $pixels.per.inch * $scale"/>
397 <xsl:variable name="depth-units">
398 <xsl:if test="@depth">
399 <xsl:call-template name="length-units">
400 <xsl:with-param name="length" select="@depth"/>
405 <xsl:variable name="depth">
406 <xsl:if test="@depth">
408 <xsl:when test="$depth-units = '%'">
409 <xsl:value-of select="@depth"/>
412 <xsl:call-template name="length-spec">
413 <xsl:with-param name="length" select="@depth"/>
420 <xsl:variable name="html.depth">
422 <xsl:when test="$ignore.image.scaling != 0"/>
423 <xsl:when test="$depth-units = '%'">
424 <xsl:value-of select="$depth"/>
426 <xsl:when test="@depth and @depth != ''">
427 <xsl:variable name="depth.in.points">
428 <xsl:call-template name="length-in-points">
429 <xsl:with-param name="length" select="$depth"/>
430 <xsl:with-param name="pixels.per.inch" select="$pixels.per.inch"/>
431 <xsl:with-param name="em.size" select="$points.per.em"/>
434 <xsl:value-of select="round($depth.in.points div 72.0 * $pixels.per.inch)"/>
440 <xsl:variable name="viewport">
442 <xsl:when test="$ignore.image.scaling != 0">0</xsl:when>
443 <xsl:when test="local-name(.) = 'inlinegraphic' or ancestor::inlinemediaobject or ancestor::inlineequation">0</xsl:when>
445 <xsl:value-of select="$make.graphic.viewport"/>
451 <xsl:message>=====================================
452 scale: <xsl:value-of select="$scale"/>, <xsl:value-of select="$scalefit"/>
453 @contentwidth <xsl:value-of select="@contentwidth"/>
454 $contentwidth <xsl:value-of select="$contentwidth"/>
455 scaled.contentwidth: <xsl:value-of select="$scaled.contentwidth"/>
456 @width: <xsl:value-of select="@width"/>
457 width: <xsl:value-of select="$width"/>
458 html.width: <xsl:value-of select="$html.width"/>
459 @contentdepth <xsl:value-of select="@contentdepth"/>
460 $contentdepth <xsl:value-of select="$contentdepth"/>
461 scaled.contentdepth: <xsl:value-of select="$scaled.contentdepth"/>
462 @depth: <xsl:value-of select="@depth"/>
463 depth: <xsl:value-of select="$depth"/>
464 html.depth: <xsl:value-of select="$html.depth"/>
465 align: <xsl:value-of select="@align"/>
466 valign: <xsl:value-of select="@valign"/></xsl:message>
469 <xsl:variable name="scaled" select="@width|@depth|@contentwidth|@contentdepth |@scale|@scalefit"/>
471 <xsl:variable name="img">
473 <xsl:when test="@format = 'SVG'">
474 <object data="{$filename}" type="image/svg+xml">
475 <xsl:call-template name="process.image.attributes">
476 <!--xsl:with-param name="alt" select="$alt"/ there's no alt here-->
477 <xsl:with-param name="html.depth" select="$html.depth"/>
478 <xsl:with-param name="html.width" select="$html.width"/>
479 <xsl:with-param name="longdesc" select="$longdesc"/>
480 <xsl:with-param name="scale" select="$scale"/>
481 <xsl:with-param name="scalefit" select="$scalefit"/>
482 <xsl:with-param name="scaled.contentdepth" select="$scaled.contentdepth"/>
483 <xsl:with-param name="scaled.contentwidth" select="$scaled.contentwidth"/>
484 <xsl:with-param name="viewport" select="$viewport"/>
486 <xsl:if test="@align">
487 <xsl:attribute name="align">
489 <xsl:when test="@align = 'center'">middle</xsl:when>
491 <xsl:value-of select="@align"/>
496 <xsl:if test="$use.embed.for.svg != 0">
497 <embed src="{$filename}" type="image/svg+xml">
498 <xsl:call-template name="process.image.attributes">
499 <!--xsl:with-param name="alt" select="$alt"/ there's no alt here -->
500 <xsl:with-param name="html.depth" select="$html.depth"/>
501 <xsl:with-param name="html.width" select="$html.width"/>
502 <xsl:with-param name="longdesc" select="$longdesc"/>
503 <xsl:with-param name="scale" select="$scale"/>
504 <xsl:with-param name="scalefit" select="$scalefit"/>
505 <xsl:with-param name="scaled.contentdepth" select="$scaled.contentdepth"/>
506 <xsl:with-param name="scaled.contentwidth" select="$scaled.contentwidth"/>
507 <xsl:with-param name="viewport" select="$viewport"/>
514 <xsl:element name="{$tag}" namespace="http://www.w3.org/1999/xhtml">
515 <xsl:if test="$tag = 'img' and ../../self::imageobjectco">
517 <xsl:when test="$scaled">
518 <!-- It might be possible to handle some scaling; needs -->
519 <!-- more investigation -->
521 <xsl:text>Warning: imagemaps not supported </xsl:text>
522 <xsl:text>on scaled images</xsl:text>
526 <xsl:attribute name="border">0</xsl:attribute>
527 <xsl:attribute name="usemap">
528 <xsl:value-of select="generate-id(../..)"/>
534 <xsl:attribute name="src">
536 <xsl:when test="$img.src.path != '' and $tag = 'img' and not(starts-with($filename, '/')) and not(contains($filename, '://'))">
537 <xsl:value-of select="$img.src.path"/>
540 <xsl:value-of select="$filename"/>
543 <xsl:if test="@align">
544 <xsl:attribute name="align">
546 <xsl:when test="@align = 'center'">middle</xsl:when>
548 <xsl:value-of select="@align"/>
554 <xsl:call-template name="process.image.attributes">
555 <xsl:with-param name="alt">
557 <xsl:when test="$alt != ''">
558 <xsl:copy-of select="$alt"/>
560 <xsl:when test="ancestor::figure">
561 <xsl:value-of select="normalize-space(ancestor::figure/title)"/>
565 <xsl:with-param name="html.depth" select="$html.depth"/>
566 <xsl:with-param name="html.width" select="$html.width"/>
567 <xsl:with-param name="longdesc" select="$longdesc"/>
568 <xsl:with-param name="scale" select="$scale"/>
569 <xsl:with-param name="scalefit" select="$scalefit"/>
570 <xsl:with-param name="scaled.contentdepth" select="$scaled.contentdepth"/>
571 <xsl:with-param name="scaled.contentwidth" select="$scaled.contentwidth"/>
572 <xsl:with-param name="viewport" select="$viewport"/>
579 <xsl:variable name="bgcolor">
580 <xsl:call-template name="dbhtml-attribute">
581 <xsl:with-param name="pis" select="../processing-instruction('dbhtml')"/>
582 <xsl:with-param name="attribute" select="'background-color'"/>
586 <xsl:variable name="use.viewport" select="$viewport != 0 and ($html.width != '' or ($html.depth != '' and $depth-units != '%') or $bgcolor != '' or @valign)"/>
589 <xsl:when test="$use.viewport">
590 <table border="0" summary="manufactured viewport for HTML img" cellspacing="0" cellpadding="0">
591 <xsl:if test="$html.width != ''">
592 <xsl:attribute name="width">
593 <xsl:value-of select="$html.width"/>
597 <xsl:if test="$html.depth != '' and $depth-units != '%'">
598 <!-- don't do this for percentages because browsers get confused -->
600 <xsl:when test="$css.decoration != 0">
601 <xsl:attribute name="style">
602 <xsl:text>height: </xsl:text>
603 <xsl:value-of select="$html.depth"/>
604 <xsl:text>px</xsl:text>
608 <xsl:attribute name="height">
609 <xsl:value-of select="$html.depth"/>
615 <xsl:if test="$bgcolor != ''">
617 <xsl:when test="$css.decoration != 0">
618 <xsl:attribute name="style">
619 <xsl:text>background-color: </xsl:text>
620 <xsl:value-of select="$bgcolor"/>
624 <xsl:attribute name="bgcolor">
625 <xsl:value-of select="$bgcolor"/>
630 <xsl:if test="@align">
631 <xsl:attribute name="align">
632 <xsl:value-of select="@align"/>
635 <xsl:if test="@valign">
636 <xsl:attribute name="valign">
637 <xsl:value-of select="@valign"/>
640 <xsl:copy-of select="$img"/>
646 <xsl:copy-of select="$img"/>
650 <xsl:if test="$tag = 'img' and ../../self::imageobjectco and not($scaled)">
651 <map name="{generate-id(../..)}">
652 <xsl:for-each select="../../areaspec//area">
653 <xsl:variable name="units">
655 <xsl:when test="@units">
656 <xsl:value-of select="@units"/>
658 <xsl:when test="../@units">
659 <xsl:value-of select="../@units"/>
661 <xsl:otherwise>calspair</xsl:otherwise>
666 <xsl:when test="$units = 'calspair'">
667 <xsl:variable name="coords" select="normalize-space(@coords)"/>
668 <xsl:variable name="p1" select="substring-before($coords, ' ')"/>
669 <xsl:variable name="p2" select="substring-after($coords, ' ')"/>
671 <xsl:variable name="x1" select="substring-before($p1,',')"/>
672 <xsl:variable name="y1" select="substring-after($p1,',')"/>
673 <xsl:variable name="x2" select="substring-before($p2,',')"/>
674 <xsl:variable name="y2" select="substring-after($p2,',')"/>
676 <xsl:variable name="x1p" select="$x1 div 100.0"/>
677 <xsl:variable name="y1p" select="$y1 div 100.0"/>
678 <xsl:variable name="x2p" select="$x2 div 100.0"/>
679 <xsl:variable name="y2p" select="$y2 div 100.0"/>
683 <xsl:text>units: </xsl:text>
684 <xsl:value-of select="$units"/>
685 <xsl:text> </xsl:text>
686 <xsl:value-of select="$x1p"/><xsl:text>, </xsl:text>
687 <xsl:value-of select="$y1p"/><xsl:text>, </xsl:text>
688 <xsl:value-of select="$x2p"/><xsl:text>, </xsl:text>
689 <xsl:value-of select="$y2p"/><xsl:text>, </xsl:text>
693 <xsl:text> </xsl:text>
694 <xsl:value-of select="$intrinsicwidth"/>
695 <xsl:text>, </xsl:text>
696 <xsl:value-of select="$intrinsicdepth"/>
700 <xsl:text> </xsl:text>
701 <xsl:value-of select="$units"/>
702 <xsl:text> </xsl:text>
703 <xsl:value-of select="round($x1p * $intrinsicwidth div 100.0)"/>
704 <xsl:text>,</xsl:text>
705 <xsl:value-of select="round($intrinsicdepth
706 - ($y1p * $intrinsicdepth div 100.0))"/>
707 <xsl:text>,</xsl:text>
708 <xsl:value-of select="round($x2p * $intrinsicwidth div 100.0)"/>
709 <xsl:text>,</xsl:text>
710 <xsl:value-of select="round($intrinsicdepth
711 - ($y2p * $intrinsicdepth div 100.0))"/>
717 <xsl:when test="@linkends">
718 <xsl:variable name="linkends" select="normalize-space(@linkends)"/>
719 <xsl:variable name="linkend">
721 <xsl:when test="contains($linkends, ' ')">
722 <xsl:value-of select="substring-before($linkends, ' ')"/>
725 <xsl:value-of select="$linkends"/>
730 <xsl:variable name="target" select="key('id', $linkend)[1]"/>
732 <xsl:if test="$target">
733 <xsl:attribute name="href">
734 <xsl:call-template name="href.target">
735 <xsl:with-param name="object" select="$target"/>
740 <xsl:when test="@xlink:href">
741 <xsl:attribute name="href">
742 <xsl:value-of select="@xlink:href"/>
748 <xsl:attribute name="alt">
749 <xsl:value-of select="alt[1]"/>
753 <xsl:attribute name="coords">
754 <xsl:value-of select="round($x1p * $intrinsicwidth div 100.0)"/>
755 <xsl:text>,</xsl:text>
756 <xsl:value-of select="round($intrinsicdepth - ($y1p * $intrinsicdepth div 100.0))"/>
757 <xsl:text>,</xsl:text>
758 <xsl:value-of select="round($x2p * $intrinsicwidth div 100.0)"/>
759 <xsl:text>,</xsl:text>
760 <xsl:value-of select="round($intrinsicdepth - ($y2p * $intrinsicdepth div 100.0))"/>
766 <xsl:text>Warning: only calspair supported </xsl:text>
767 <xsl:text>in imageobjectco</xsl:text>
776 <xsl:template name="process.image.attributes">
777 <xsl:param name="alt"/>
778 <xsl:param name="html.width"/>
779 <xsl:param name="html.depth"/>
780 <xsl:param name="longdesc"/>
781 <xsl:param name="scale"/>
782 <xsl:param name="scalefit"/>
783 <xsl:param name="scaled.contentdepth"/>
784 <xsl:param name="scaled.contentwidth"/>
785 <xsl:param name="viewport"/>
788 <xsl:when test="@contentwidth or @contentdepth">
789 <!-- ignore @width/@depth, @scale, and @scalefit if specified -->
790 <xsl:if test="@contentwidth">
791 <xsl:attribute name="width">
792 <xsl:value-of select="$scaled.contentwidth"/>
795 <xsl:if test="@contentdepth">
796 <xsl:attribute name="height">
797 <xsl:value-of select="$scaled.contentdepth"/>
802 <xsl:when test="number($scale) != 1.0">
803 <!-- scaling is always uniform, so we only have to specify one dimension -->
804 <!-- ignore @scalefit if specified -->
805 <xsl:attribute name="width">
806 <xsl:value-of select="$scaled.contentwidth"/>
810 <xsl:when test="$scalefit != 0">
812 <xsl:when test="contains($html.width, '%')">
814 <xsl:when test="$viewport != 0">
815 <!-- The *viewport* will be scaled, so use 100% here! -->
816 <xsl:attribute name="width">
817 <xsl:value-of select="'100%'"/>
821 <xsl:attribute name="width">
822 <xsl:value-of select="$html.width"/>
828 <xsl:when test="contains($html.depth, '%')">
829 <!-- HTML doesn't deal with this case very well...do nothing -->
832 <xsl:when test="$scaled.contentwidth != '' and $html.width != '' and $scaled.contentdepth != '' and $html.depth != ''">
833 <!-- scalefit should not be anamorphic; figure out which direction -->
834 <!-- has the limiting scale factor and scale in that direction -->
836 <xsl:when test="$html.width div $scaled.contentwidth > $html.depth div $scaled.contentdepth">
837 <xsl:attribute name="height">
838 <xsl:value-of select="$html.depth"/>
842 <xsl:attribute name="width">
843 <xsl:value-of select="$html.width"/>
849 <xsl:when test="$scaled.contentwidth != '' and $html.width != ''">
850 <xsl:attribute name="width">
851 <xsl:value-of select="$html.width"/>
855 <xsl:when test="$scaled.contentdepth != '' and $html.depth != ''">
856 <xsl:attribute name="height">
857 <xsl:value-of select="$html.depth"/>
864 <xsl:if test="$alt != ''">
865 <xsl:attribute name="alt">
866 <xsl:value-of select="$alt"/>
870 <xsl:if test="$longdesc != ''">
871 <xsl:attribute name="longdesc">
872 <xsl:value-of select="$longdesc"/>
876 <xsl:if test="@align and $viewport = 0">
877 <xsl:attribute name="align">
879 <xsl:when test="@align = 'center'">middle</xsl:when>
881 <xsl:value-of select="@align"/>
888 <!-- ==================================================================== -->
890 <xsl:template match="graphic">
892 <xsl:when test="parent::inlineequation">
893 <xsl:call-template name="anchor"/>
894 <xsl:call-template name="process.image"/>
898 <xsl:if test="@align">
899 <xsl:attribute name="align">
900 <xsl:value-of select="@align"/>
903 <xsl:call-template name="anchor"/>
904 <xsl:call-template name="process.image"/>
910 <xsl:template match="inlinegraphic">
911 <xsl:variable name="filename">
913 <xsl:when test="@entityref">
914 <xsl:value-of select="unparsed-entity-uri(@entityref)"/>
917 <xsl:apply-templates select="@fileref"/>
927 <xsl:when test="@format='linespecific'">
929 <xsl:when test="$use.extensions != '0' and $textinsert.extension != '0'">
931 <xsl:when test="element-available('stext:insertfile')">
932 <stext:insertfile href="{$filename}" encoding="{$textdata.default.encoding}"/>
934 <xsl:when test="element-available('xtext:insertfile')">
935 <xtext:insertfile href="{$filename}"/>
938 <xsl:message terminate="yes">
939 <xsl:text>No insertfile extension available.</xsl:text>
945 <a xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" href="{$filename}"/>
950 <xsl:call-template name="process.image"/>
955 <!-- ==================================================================== -->
957 <xsl:template match="mediaobject|mediaobjectco">
959 <xsl:variable name="olist" select="imageobject|imageobjectco |videoobject|audioobject |textobject"/>
961 <xsl:variable name="object.index">
962 <xsl:call-template name="select.mediaobject.index">
963 <xsl:with-param name="olist" select="$olist"/>
964 <xsl:with-param name="count" select="1"/>
968 <xsl:variable name="object" select="$olist[position() = $object.index]"/>
970 <xsl:variable name="align">
971 <xsl:value-of select="$object/descendant::imagedata[@align][1]/@align"/>
974 <div class="{name(.)}">
975 <xsl:if test="$align != '' ">
976 <xsl:attribute name="align">
977 <xsl:value-of select="$align"/>
984 <xsl:apply-templates select="$object"/>
985 <xsl:apply-templates select="caption"/>
989 <xsl:template match="inlinemediaobject">
990 <span class="{name(.)}">
994 <xsl:call-template name="select.mediaobject"/>
998 <xsl:template match="programlisting/inlinemediaobject |screen/inlinemediaobject" priority="2">
999 <!-- the additional span causes problems in some cases -->
1000 <xsl:call-template name="select.mediaobject"/>
1003 <!-- ==================================================================== -->
1005 <xsl:template match="imageobjectco">
1009 <xsl:apply-templates select="imageobject"/>
1010 <xsl:apply-templates select="calloutlist"/>
1013 <xsl:template match="imageobject">
1015 <xsl:when xmlns:svg="http://www.w3.org/2000/svg" test="svg:*">
1016 <xsl:apply-templates/>
1019 <xsl:apply-templates select="imagedata"/>
1024 <xsl:template match="imagedata">
1025 <xsl:variable name="filename">
1026 <xsl:call-template name="mediaobject.filename">
1027 <xsl:with-param name="object" select=".."/>
1028 </xsl:call-template>
1032 <xsl:when test="@format='linespecific'">
1034 <xsl:when test="$use.extensions != '0' and $textinsert.extension != '0'">
1036 <xsl:when test="element-available('stext:insertfile')">
1037 <stext:insertfile href="{$filename}" encoding="{$textdata.default.encoding}"/>
1039 <xsl:when test="element-available('xtext:insertfile')">
1040 <xtext:insertfile href="{$filename}"/>
1043 <xsl:message terminate="yes">
1044 <xsl:text>No insertfile extension available.</xsl:text>
1050 <a xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" href="{$filename}"/>
1055 <xsl:variable name="longdesc.uri">
1056 <xsl:call-template name="longdesc.uri">
1057 <xsl:with-param name="mediaobject" select="ancestor::imageobject/parent::*"/>
1058 </xsl:call-template>
1061 <xsl:variable name="phrases" select="ancestor::mediaobject/textobject[phrase] |ancestor::inlinemediaobject/textobject[phrase] |ancestor::mediaobjectco/textobject[phrase]"/>
1063 <xsl:call-template name="process.image">
1064 <xsl:with-param name="alt">
1065 <xsl:apply-templates select="$phrases[not(@role) or @role!='tex'][1]"/>
1067 <xsl:with-param name="longdesc">
1068 <xsl:call-template name="write.longdesc">
1069 <xsl:with-param name="mediaobject" select="ancestor::imageobject/parent::*"/>
1070 </xsl:call-template>
1072 </xsl:call-template>
1074 <xsl:if test="$html.longdesc != 0 and $html.longdesc.link != 0 and ancestor::imageobject/parent::*/textobject[not(phrase)]">
1075 <xsl:call-template name="longdesc.link">
1076 <xsl:with-param name="longdesc.uri" select="$longdesc.uri"/>
1077 </xsl:call-template>
1083 <!-- ==================================================================== -->
1085 <xsl:template name="longdesc.uri">
1086 <xsl:param name="mediaobject" select="."/>
1088 <xsl:if test="$html.longdesc">
1089 <xsl:if test="$mediaobject/textobject[not(phrase)]">
1090 <xsl:variable name="image-id">
1091 <xsl:call-template name="object.id">
1092 <xsl:with-param name="object" select="$mediaobject"/>
1093 </xsl:call-template>
1095 <xsl:variable name="dbhtml.dir">
1096 <xsl:call-template name="dbhtml-dir"/>
1098 <xsl:variable name="filename">
1099 <xsl:call-template name="make-relative-filename">
1100 <xsl:with-param name="base.dir">
1102 <xsl:when test="$dbhtml.dir != ''">
1103 <xsl:value-of select="$dbhtml.dir"/>
1106 <xsl:value-of select="$base.dir"/>
1110 <xsl:with-param name="base.name" select="concat('ld-',$image-id,$html.ext)"/>
1111 </xsl:call-template>
1114 <xsl:value-of select="$filename"/>
1119 <xsl:template name="write.longdesc">
1120 <xsl:param name="mediaobject" select="."/>
1121 <xsl:if test="$html.longdesc != 0 and $mediaobject/textobject[not(phrase)]">
1122 <xsl:variable name="filename">
1123 <xsl:call-template name="longdesc.uri">
1124 <xsl:with-param name="mediaobject" select="$mediaobject"/>
1125 </xsl:call-template>
1128 <xsl:value-of select="$filename"/>
1130 <xsl:call-template name="write.chunk">
1131 <xsl:with-param name="filename" select="$filename"/>
1132 <xsl:with-param name="quiet" select="$chunk.quietly"/>
1133 <xsl:with-param name="content">
1134 <xsl:call-template name="user.preroot"/>
1137 <xsl:call-template name="system.head.content"/>
1138 <xsl:call-template name="head.content">
1139 <xsl:with-param name="title" select="'Long Description'"/>
1140 </xsl:call-template>
1141 <xsl:call-template name="user.head.content"/>
1144 <xsl:call-template name="body.attributes"/>
1145 <xsl:for-each select="$mediaobject/textobject[not(phrase)]">
1146 <xsl:apply-templates select="./*"/>
1151 </xsl:call-template>
1155 <xsl:template name="longdesc.link">
1156 <xsl:param name="longdesc.uri" select="''"/>
1158 <xsl:variable name="this.uri">
1159 <xsl:call-template name="make-relative-filename">
1160 <xsl:with-param name="base.dir" select="$base.dir"/>
1161 <xsl:with-param name="base.name">
1162 <xsl:call-template name="href.target.uri"/>
1164 </xsl:call-template>
1167 <xsl:variable name="href.to">
1168 <xsl:call-template name="trim.common.uri.paths">
1169 <xsl:with-param name="uriA" select="$longdesc.uri"/>
1170 <xsl:with-param name="uriB" select="$this.uri"/>
1171 <xsl:with-param name="return" select="'A'"/>
1172 </xsl:call-template>
1175 <div class="longdesc-link" align="right">
1177 <span class="longdesc-link">
1178 <xsl:text>[</xsl:text>
1179 <a href="{$href.to}" target="longdesc">D</a>
1180 <xsl:text>]</xsl:text>
1185 <!-- ==================================================================== -->
1187 <xsl:template match="videoobject">
1188 <xsl:apply-templates select="videodata"/>
1191 <xsl:template match="videodata">
1192 <xsl:call-template name="process.image">
1193 <xsl:with-param name="tag" select="'embed'"/>
1194 <xsl:with-param name="alt">
1195 <xsl:apply-templates select="(../../textobject/phrase)[1]"/>
1197 </xsl:call-template>
1200 <!-- ==================================================================== -->
1202 <xsl:template match="audioobject">
1203 <xsl:apply-templates select="audiodata"/>
1206 <xsl:template match="audiodata">
1207 <xsl:call-template name="process.image">
1208 <xsl:with-param name="tag" select="'embed'"/>
1209 <xsl:with-param name="alt">
1210 <xsl:apply-templates select="(../../textobject/phrase)[1]"/>
1212 </xsl:call-template>
1215 <!-- ==================================================================== -->
1217 <xsl:template match="textobject">
1218 <xsl:apply-templates/>
1221 <xsl:template match="textdata">
1222 <xsl:variable name="filename">
1224 <xsl:when test="@entityref">
1225 <xsl:value-of select="unparsed-entity-uri(@entityref)"/>
1228 <xsl:apply-templates select="@fileref"/>
1233 <xsl:variable name="encoding">
1235 <xsl:when test="@encoding">
1236 <xsl:value-of select="@encoding"/>
1239 <xsl:value-of select="$textdata.default.encoding"/>
1245 <xsl:when test="$use.extensions != '0' and $textinsert.extension != '0'">
1247 <xsl:when test="element-available('stext:insertfile')">
1248 <stext:insertfile href="{$filename}" encoding="{$encoding}"/>
1250 <xsl:when test="element-available('xtext:insertfile')">
1251 <xtext:insertfile href="{$filename}"/>
1254 <xsl:message terminate="yes">
1255 <xsl:text>No insertfile extension available.</xsl:text>
1261 <a xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" href="{$filename}"/>
1266 <!-- ==================================================================== -->
1268 <xsl:template match="caption">
1269 <div class="{name(.)}">
1270 <xsl:if test="@align = 'right' or @align = 'left' or @align='center'">
1271 <xsl:attribute name="align"><xsl:value-of select="@align"/></xsl:attribute>
1273 <xsl:apply-templates/>
1277 <!-- ==================================================================== -->
1278 <!-- "Support" for SVG -->
1280 <xsl:template xmlns:svg="http://www.w3.org/2000/svg" match="svg:*">
1282 <xsl:copy-of select="@*"/>
1283 <xsl:apply-templates/>
1287 <!-- Resolve xml:base attributes -->
1288 <xsl:template match="@fileref">
1289 <!-- need a check for absolute urls -->
1291 <xsl:when test="contains(., ':')">
1292 <!-- it has a uri scheme so it is an absolute uri -->
1293 <xsl:value-of select="."/>
1296 <!-- its a relative uri -->
1297 <xsl:call-template name="relative-uri">
1298 </xsl:call-template>