]> git.evergreen-ils.org Git - working/Evergreen.git/blob - stylesheets/evergreen_docbook_files/evergreen_fo_graphics.xsl
(no commit message)
[working/Evergreen.git] / stylesheets / evergreen_docbook_files / evergreen_fo_graphics.xsl
1 <?xml version='1.0'?>
2 <!DOCTYPE xsl:stylesheet [
3 <!ENTITY lowercase "'abcdefghijklmnopqrstuvwxyz'">
4 <!ENTITY uppercase "'ABCDEFGHIJKLMNOPQRSTUVWXYZ'">
5  ]>
6 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
7                 xmlns:d="http://docbook.org/ns/docbook"
8 xmlns:fo="http://www.w3.org/1999/XSL/Format"
9                 xmlns:xlink="http://www.w3.org/1999/xlink"
10                 xmlns:stext="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.TextFactory"
11                 xmlns:xtext="com.nwalsh.xalan.Text"
12                 xmlns:lxslt="http://xml.apache.org/xslt"
13                 exclude-result-prefixes="xlink stext xtext lxslt d"
14                 extension-element-prefixes="stext xtext"
15                 version='1.0'>
16
17 <!-- ********************************************************************
18      $Id: graphics.xsl 8144 2008-10-25 09:41:24Z mzjn $
19      ********************************************************************
20
21      This file is part of the XSL DocBook Stylesheet distribution.
22      See ../README or http://docbook.sf.net/release/xsl/current/ for
23      copyright and other information.
24
25      Contributors:
26      Colin Paul Adams, <colin@colina.demon.co.uk>
27      Paul Grosso, <pgrosso@arbortext.com>
28
29      ******************************************************************** -->
30
31 <!-- ==================================================================== -->
32 <!-- Graphic format tests for the FO backend -->
33
34 <xsl:param name="graphic.notations">
35   <!-- n.b. exactly one leading space, one trailing space, and one inter-word space -->
36   <xsl:choose>
37     <xsl:when test="$passivetex.extensions != 0">
38       <xsl:text> PNG PDF JPG JPEG linespecific </xsl:text>
39     </xsl:when>
40     <xsl:when test="$fop1.extensions != 0">
41       <xsl:text> BMP GIF TIFF SVG PNG EPS JPG JPEG linespecific </xsl:text>
42     </xsl:when>
43     <xsl:when test="$fop.extensions != 0">
44       <xsl:text> BMP GIF TIFF SVG PNG EPS JPG JPEG linespecific </xsl:text>
45     </xsl:when>
46     <xsl:when test="$arbortext.extensions != 0">
47       <xsl:text> PNG PDF JPG JPEG linespecific GIF GIF87a GIF89a TIFF BMP </xsl:text>
48     </xsl:when>
49     <xsl:when test="$xep.extensions != 0">
50       <xsl:text> SVG PNG PDF JPG JPEG linespecific GIF GIF87a GIF89a TIFF BMP </xsl:text>
51     </xsl:when>
52     <xsl:otherwise>
53       <xsl:text> PNG PDF JPG JPEG linespecific GIF GIF87a GIF89a TIFF BMP </xsl:text>
54     </xsl:otherwise>
55   </xsl:choose>
56 </xsl:param>
57
58 <xsl:template name="is.graphic.format">
59   <xsl:param name="format"/>
60   <xsl:if test="contains($graphic.notations, concat(' ',$format,' '))">1</xsl:if>
61 </xsl:template>
62
63 <xsl:param name="graphic.extensions">
64   <!-- n.b. exactly one leading space, one trailing space, and one inter-word space -->
65   <xsl:choose>
66     <xsl:when test="$passivetex.extensions != 0">
67       <xsl:text> png pdf jpg jpeg </xsl:text>
68     </xsl:when>
69     <xsl:when test="$fop1.extensions != 0">
70       <xsl:text> bmp gif tif tiff svg png pdf jpg jpeg eps </xsl:text>
71     </xsl:when>
72     <xsl:when test="$fop.extensions != 0">
73       <xsl:text> bmp gif tif tiff svg png pdf jpg jpeg eps </xsl:text>
74     </xsl:when>
75     <xsl:when test="$arbortext.extensions != 0">
76       <xsl:text> png pdf jpg jpeg gif tif tiff bmp </xsl:text>
77     </xsl:when>
78     <xsl:when test="$xep.extensions != 0">
79       <xsl:text> svg png pdf jpg jpeg gif tif tiff bmp eps </xsl:text>
80     </xsl:when>
81     <xsl:otherwise>
82       <xsl:text> svg png pdf jpg jpeg gif tif tiff bmp eps </xsl:text>
83     </xsl:otherwise>
84   </xsl:choose>
85 </xsl:param>
86
87 <xsl:template name="is.graphic.extension">
88   <xsl:param name="ext"/>
89   <xsl:variable name="lcext" select="translate($ext,
90                                        'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
91                                        'abcdefghijklmnopqrstuvwxyz')"/>
92
93   <xsl:if test="contains($graphic.extensions,
94                          concat(' ', $lcext, ' '))">1</xsl:if>
95 </xsl:template>
96
97 <xsl:template name="graphic.format.content-type">
98   <xsl:param name="format"/>
99   <xsl:variable name="is.graphic.format">
100     <xsl:call-template name="is.graphic.format">
101       <xsl:with-param name="format" select="$format"/>
102     </xsl:call-template>
103   </xsl:variable>
104   <xsl:if test="$is.graphic.format">
105     <xsl:choose>
106       <xsl:when test="$format = ''"></xsl:when>
107       <xsl:when test="$format = 'linespecific'"></xsl:when>
108       <xsl:when test="$format = 'PS'">application/postscript</xsl:when>
109       <xsl:when test="$format = 'PDF'">application/pdf</xsl:when>
110       <xsl:when test="$format = 'PNG'">image/png</xsl:when>
111       <xsl:when test="$format = 'SVG'">image/svg+xml</xsl:when>
112       <xsl:when test="$format = 'JPG'">image/jpeg</xsl:when>
113       <xsl:when test="$format = 'GIF87a'">image/gif</xsl:when>
114       <xsl:when test="$format = 'GIF89a'">image/gif</xsl:when>
115       <xsl:otherwise>
116           <xsl:value-of select="concat('image/', 
117             translate($format, &uppercase;, &lowercase;))"/>
118       </xsl:otherwise>
119     </xsl:choose>
120   </xsl:if>
121 </xsl:template>
122
123
124 <!-- ==================================================================== -->
125
126 <xsl:template match="d:screenshot">
127   <fo:block>
128     <xsl:apply-templates/>
129   </fo:block>
130 </xsl:template>
131
132 <xsl:template match="d:screeninfo">
133 </xsl:template>
134
135 <!-- ==================================================================== -->
136 <!-- Override these templates for FO -->
137 <!-- ==================================================================== -->
138
139 <xsl:template name="process.image">
140   <!-- When this template is called, the current node should be  -->
141   <!-- a graphic, inlinegraphic, imagedata, or videodata. All    -->
142   <!-- those elements have the same set of attributes, so we can -->
143   <!-- handle them all in one place.                             -->
144
145   <xsl:variable name="scalefit">
146     <xsl:choose>
147       <xsl:when test="$ignore.image.scaling != 0">0</xsl:when>
148       <xsl:when test="@contentwidth">0</xsl:when>
149       <xsl:when test="@contentdepth and 
150                       @contentdepth != '100%'">0</xsl:when>
151       <xsl:when test="@scale">0</xsl:when>
152       <xsl:when test="@scalefit"><xsl:value-of select="@scalefit"/></xsl:when>
153       <xsl:when test="@width or @depth">1</xsl:when>
154       <xsl:when test="$default.image.width != ''">1</xsl:when>
155       <xsl:otherwise>0</xsl:otherwise>
156     </xsl:choose>
157   </xsl:variable>
158
159   <xsl:variable name="scale">
160     <xsl:choose>
161       <xsl:when test="$ignore.image.scaling != 0">0</xsl:when>
162       <xsl:when test="@contentwidth or @contentdepth">1.0</xsl:when>
163       <xsl:when test="@scale">
164         <xsl:value-of select="@scale div 100.0"/>
165       </xsl:when>
166       <!-- added next line to adjust scaling where scalefit = 1 -->
167       <xsl:when test="@scalefit and @scalefit = '1'">1.0</xsl:when>
168       <xsl:otherwise>0.75</xsl:otherwise>
169     </xsl:choose>
170   </xsl:variable>
171
172   <xsl:variable name="filename">
173     <xsl:choose>
174       <xsl:when test="local-name(.) = 'graphic'
175                       or local-name(.) = 'inlinegraphic'">
176         <!-- handle legacy graphic and inlinegraphic by new template --> 
177         <xsl:call-template name="mediaobject.filename">
178           <xsl:with-param name="object" select="."/>
179         </xsl:call-template>
180       </xsl:when>
181       <xsl:otherwise>
182         <!-- imagedata, videodata, audiodata -->
183         <xsl:call-template name="mediaobject.filename">
184           <xsl:with-param name="object" select=".."/>
185         </xsl:call-template>
186       </xsl:otherwise>
187     </xsl:choose>
188   </xsl:variable>
189
190   <xsl:variable name="content-type">
191     <xsl:if test="@format">
192       <xsl:call-template name="graphic.format.content-type">
193         <xsl:with-param name="format" select="@format"/>
194       </xsl:call-template>
195     </xsl:if>
196   </xsl:variable>
197
198   <xsl:variable name="bgcolor">
199     <xsl:call-template name="pi.dbfo_background-color">
200       <xsl:with-param name="node" select=".."/>
201     </xsl:call-template>
202   </xsl:variable>
203
204   <fo:external-graphic>
205     <xsl:attribute name="src">
206       <xsl:call-template name="fo-external-image">
207         <xsl:with-param name="filename">
208           <xsl:if test="$img.src.path != '' and
209                         not(starts-with($filename, '/')) and
210                         not(contains($filename, '://'))">
211             <xsl:value-of select="$img.src.path"/>
212           </xsl:if>
213           <xsl:value-of select="$filename"/>
214         </xsl:with-param>
215       </xsl:call-template>
216     </xsl:attribute>
217
218     <xsl:attribute name="width">
219       <xsl:choose>
220         <xsl:when test="$ignore.image.scaling != 0">auto</xsl:when>
221         <xsl:when test="contains(@width,'%')">
222           <xsl:value-of select="@width"/>
223         </xsl:when>
224         <xsl:when test="@width and not(@width = '')">
225           <xsl:call-template name="length-spec">
226             <xsl:with-param name="length" select="@width"/>
227             <xsl:with-param name="default.units" select="'px'"/>
228           </xsl:call-template>
229         </xsl:when>
230         <xsl:when test="not(@depth) and $default.image.width != ''">
231           <xsl:call-template name="length-spec">
232             <xsl:with-param name="length" select="$default.image.width"/>
233             <xsl:with-param name="default.units" select="'px'"/>
234           </xsl:call-template>
235         </xsl:when>
236         <xsl:otherwise>auto</xsl:otherwise>
237       </xsl:choose>
238     </xsl:attribute>
239
240     <xsl:attribute name="height">
241       <xsl:choose>
242         <xsl:when test="$ignore.image.scaling != 0">auto</xsl:when>
243         <xsl:when test="contains(@depth,'%')">
244           <xsl:value-of select="@depth"/>
245         </xsl:when>
246         <xsl:when test="@depth">
247           <xsl:call-template name="length-spec">
248             <xsl:with-param name="length" select="@depth"/>
249             <xsl:with-param name="default.units" select="'px'"/>
250           </xsl:call-template>
251         </xsl:when>
252         <xsl:otherwise>auto</xsl:otherwise>
253       </xsl:choose>
254     </xsl:attribute>
255
256     <xsl:attribute name="content-width">
257       <xsl:choose>
258         <xsl:when test="$ignore.image.scaling != 0">auto</xsl:when>
259         <xsl:when test="contains(@contentwidth,'%')">
260           <xsl:value-of select="@contentwidth"/>
261         </xsl:when>
262         <xsl:when test="@contentwidth">
263           <xsl:call-template name="length-spec">
264             <xsl:with-param name="length" select="@contentwidth"/>
265             <xsl:with-param name="default.units" select="'px'"/>
266           </xsl:call-template>
267         </xsl:when>
268         <xsl:when test="number($scale) != 1.0">
269           <xsl:value-of select="$scale * 100"/>
270           <xsl:text>%</xsl:text>
271         </xsl:when>
272         <xsl:when test="$scalefit = 1">scale-to-fit</xsl:when>
273         <xsl:otherwise>auto</xsl:otherwise>
274       </xsl:choose>
275     </xsl:attribute>
276
277     <xsl:attribute name="content-height">
278       <xsl:choose>
279         <xsl:when test="$ignore.image.scaling != 0">auto</xsl:when>
280         <xsl:when test="contains(@contentdepth,'%')">
281           <xsl:value-of select="@contentdepth"/>
282         </xsl:when>
283         <xsl:when test="@contentdepth">
284           <xsl:call-template name="length-spec">
285             <xsl:with-param name="length" select="@contentdepth"/>
286             <xsl:with-param name="default.units" select="'px'"/>
287           </xsl:call-template>
288         </xsl:when>
289         <xsl:when test="number($scale) != 1.0">
290           <xsl:value-of select="$scale * 100"/>
291           <xsl:text>%</xsl:text>
292         </xsl:when>
293         <xsl:when test="$scalefit = 1">scale-to-fit</xsl:when>
294         <xsl:otherwise>auto</xsl:otherwise>
295       </xsl:choose>
296     </xsl:attribute>
297
298     <xsl:if test="$content-type != ''">
299       <xsl:attribute name="content-type">
300         <xsl:value-of select="concat('content-type:',$content-type)"/>
301       </xsl:attribute>
302     </xsl:if>
303
304     <xsl:if test="$bgcolor != ''">
305       <xsl:attribute name="background-color">
306         <xsl:value-of select="$bgcolor"/>
307       </xsl:attribute>
308     </xsl:if>
309
310     <xsl:if test="@align">
311       <xsl:attribute name="text-align">
312         <xsl:value-of select="@align"/>
313       </xsl:attribute>
314     </xsl:if>
315
316     <xsl:if test="@valign">
317       <xsl:attribute name="display-align">
318         <xsl:choose>
319           <xsl:when test="@valign = 'top'">before</xsl:when>
320           <xsl:when test="@valign = 'middle'">center</xsl:when>
321           <xsl:when test="@valign = 'bottom'">after</xsl:when>
322           <xsl:otherwise>auto</xsl:otherwise>
323         </xsl:choose>
324       </xsl:attribute>
325     </xsl:if>
326   </fo:external-graphic>
327 </xsl:template>
328
329 <!-- ==================================================================== -->
330
331 <xsl:template match="d:graphic">
332   <xsl:choose>
333     <xsl:when test="parent::d:inlineequation">
334       <xsl:call-template name="process.image"/>
335     </xsl:when>
336     <xsl:otherwise>
337       <fo:block>
338         <xsl:if test="@align">
339           <xsl:attribute name="text-align">
340             <xsl:value-of select="@align"/>
341           </xsl:attribute>
342         </xsl:if>
343         <xsl:call-template name="process.image"/>
344       </fo:block>
345     </xsl:otherwise>
346   </xsl:choose>
347 </xsl:template>
348
349 <xsl:template match="d:inlinegraphic">
350   <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
351   <xsl:variable name="filename">
352     <xsl:choose>
353       <xsl:when test="@entityref">
354         <xsl:value-of select="unparsed-entity-uri(@entityref)"/>
355       </xsl:when>
356       <xsl:otherwise>
357         <xsl:apply-templates select="@fileref"/>
358       </xsl:otherwise>
359     </xsl:choose>
360   </xsl:variable>
361
362   <xsl:choose>
363     <xsl:when test="@format='linespecific'">
364       <xsl:choose>
365         <xsl:when test="$use.extensions != '0'
366                         and $textinsert.extension != '0'">
367           <xsl:choose>
368             <xsl:when test="contains($vendor, 'SAXON')">
369               <stext:insertfile href="{$filename}" encoding="{$textdata.default.encoding}"/>
370             </xsl:when>
371             <xsl:when test="contains($vendor, 'Apache Software Foundation')">
372               <xtext:insertfile href="{$filename}"/>
373             </xsl:when>
374             <xsl:otherwise>
375               <xsl:message terminate="yes">
376                 <xsl:text>Don't know how to insert files with </xsl:text>
377                 <xsl:value-of select="$vendor"/>
378               </xsl:message>
379             </xsl:otherwise>
380           </xsl:choose>
381         </xsl:when>
382         <xsl:otherwise>
383           <xsl:message terminate="yes">
384             <xsl:text>Cannot insert </xsl:text><xsl:value-of select="$filename"/>
385             <xsl:text>. Check use.extensions and textinsert.extension parameters.</xsl:text> 
386           </xsl:message>
387         </xsl:otherwise>
388       </xsl:choose>
389     </xsl:when>
390     <xsl:otherwise>
391       <xsl:call-template name="process.image"/>
392     </xsl:otherwise>
393   </xsl:choose>
394 </xsl:template>
395
396 <!-- ==================================================================== -->
397
398 <xsl:template match="d:mediaobject|d:mediaobjectco">
399
400   <xsl:variable name="olist" select="d:imageobject|d:imageobjectco
401                      |d:videoobject|d:audioobject
402                      |d:textobject"/>
403
404   <xsl:variable name="object.index">
405     <xsl:call-template name="select.mediaobject.index">
406       <xsl:with-param name="olist" select="$olist"/>
407       <xsl:with-param name="count" select="1"/>
408     </xsl:call-template>
409   </xsl:variable>
410
411   <xsl:variable name="object" select="$olist[position() = $object.index]"/>
412
413   <xsl:variable name="align">
414     <xsl:value-of select="$object/descendant::d:imagedata[@align][1]/@align"/>
415   </xsl:variable>
416
417   <xsl:variable name="id">
418     <xsl:call-template name="object.id"/>
419   </xsl:variable>
420
421   <fo:block id="{$id}">
422     <xsl:if test="$align != '' ">
423       <xsl:attribute name="text-align">
424         <xsl:value-of select="$align"/>
425       </xsl:attribute>
426     </xsl:if>
427
428     <xsl:apply-templates select="$object"/>
429     <xsl:apply-templates select="d:caption"/>
430   </fo:block>
431 </xsl:template>
432
433 <xsl:template match="d:inlinemediaobject">
434   <xsl:call-template name="select.mediaobject"/>
435 </xsl:template>
436
437 <!-- ==================================================================== -->
438
439 <xsl:template match="d:imageobjectco">
440   <xsl:apply-templates select="d:imageobject"/>
441   <xsl:apply-templates select="d:calloutlist"/>
442 </xsl:template>
443
444 <xsl:template match="d:imageobject">
445   <xsl:choose>
446     <xsl:when test="d:imagedata">
447       <xsl:apply-templates select="d:imagedata"/>
448     </xsl:when>
449     <xsl:otherwise>
450       <fo:instream-foreign-object>
451         <xsl:apply-templates mode="copy-all"/>
452       </fo:instream-foreign-object>
453     </xsl:otherwise>
454   </xsl:choose>
455 </xsl:template>
456
457 <!-- ==================================================================== -->
458
459 <xsl:template match="*" mode="copy-all">
460   <xsl:copy>
461     <xsl:for-each select="@*">
462       <xsl:copy/>
463     </xsl:for-each>
464     <xsl:apply-templates mode="copy-all"/>
465   </xsl:copy>
466 </xsl:template>
467
468 <xsl:template match="text()|comment()|processing-instruction()" mode="copy-all">
469   <xsl:copy/>
470 </xsl:template>
471
472 <!-- ==================================================================== -->
473
474 <xsl:template match="d:imagedata">
475   <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
476   <xsl:variable name="filename">
477     <xsl:call-template name="mediaobject.filename">
478       <xsl:with-param name="object" select=".."/>
479     </xsl:call-template>
480   </xsl:variable>
481
482   <xsl:choose>
483     <xsl:when test="mml:*" xmlns:mml="http://www.w3.org/1998/Math/MathML">
484       <xsl:apply-templates/>
485     </xsl:when>
486   
487     <xsl:when test="@format='linespecific'">
488       <xsl:choose>
489         <xsl:when test="$use.extensions != '0'
490                         and $textinsert.extension != '0'">
491           <xsl:choose>
492             <xsl:when test="contains($vendor, 'SAXON')">
493               <stext:insertfile href="{$filename}" encoding="{$textdata.default.encoding}"/>
494             </xsl:when>
495             <xsl:when test="contains($vendor, 'Apache Software Foundation')">
496               <xtext:insertfile href="{$filename}"/>
497             </xsl:when>
498             <xsl:otherwise>
499               <xsl:message terminate="yes">
500                 <xsl:text>Don't know how to insert files with </xsl:text>
501                 <xsl:value-of select="$vendor"/>
502               </xsl:message>
503             </xsl:otherwise>
504           </xsl:choose>
505         </xsl:when>
506         <xsl:otherwise>
507           <xsl:message terminate="yes">
508             <xsl:text>Cannot insert </xsl:text><xsl:value-of select="$filename"/>
509             <xsl:text>. Check use.extensions and textinsert.extension parameters.</xsl:text> 
510           </xsl:message>
511         </xsl:otherwise>
512       </xsl:choose>
513     </xsl:when>
514     <xsl:otherwise>
515       <xsl:call-template name="process.image"/>
516     </xsl:otherwise>
517   </xsl:choose>
518 </xsl:template>
519
520 <!-- ==================================================================== -->
521
522 <xsl:template match="d:videoobject">
523   <xsl:apply-templates select="d:videodata"/>
524 </xsl:template>
525
526 <xsl:template match="d:videodata">
527   <xsl:call-template name="process.image"/>
528 </xsl:template>
529
530 <!-- ==================================================================== -->
531
532 <xsl:template match="d:audioobject">
533   <xsl:apply-templates select="d:audiodata"/>
534 </xsl:template>
535
536 <xsl:template match="d:audiodata">
537   <xsl:call-template name="process.image"/>
538 </xsl:template>
539
540 <!-- ==================================================================== -->
541
542 <xsl:template match="d:textobject">
543   <xsl:apply-templates/>
544 </xsl:template>
545
546 <xsl:template match="d:textdata">
547   <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
548   <xsl:variable name="filename">
549     <xsl:choose>
550       <xsl:when test="@entityref">
551         <xsl:value-of select="unparsed-entity-uri(@entityref)"/>
552       </xsl:when>
553       <xsl:otherwise>
554         <xsl:apply-templates select="@fileref"/>
555       </xsl:otherwise>
556     </xsl:choose>
557   </xsl:variable>
558
559   <xsl:variable name="encoding">
560     <xsl:choose>
561       <xsl:when test="@encoding">
562         <xsl:value-of select="@encoding"/>
563       </xsl:when>
564       <xsl:otherwise>
565         <xsl:value-of select="$textdata.default.encoding"/>
566       </xsl:otherwise>
567     </xsl:choose>
568   </xsl:variable>
569
570   <xsl:choose>
571     <xsl:when test="$use.extensions != '0'
572                     and $textinsert.extension != '0'">
573       <xsl:choose>
574         <xsl:when test="element-available('stext:insertfile')">
575           <stext:insertfile href="{$filename}" encoding="{$encoding}"/>
576         </xsl:when>
577         <xsl:when test="element-available('xtext:insertfile')">
578           <xtext:insertfile href="{$filename}"/>
579         </xsl:when>
580         <xsl:otherwise>
581           <xsl:message terminate="yes">
582             <xsl:text>Don't know how to insert files with </xsl:text>
583             <xsl:value-of select="$vendor"/>
584           </xsl:message>
585         </xsl:otherwise>
586       </xsl:choose>
587     </xsl:when>
588     <xsl:otherwise>
589       <xsl:message terminate="yes">
590         <xsl:text>Cannot insert </xsl:text><xsl:value-of select="$filename"/>
591         <xsl:text>. Check use.extensions and textinsert.extension parameters.</xsl:text> 
592       </xsl:message>
593     </xsl:otherwise>
594   </xsl:choose>
595 </xsl:template>
596
597 <!-- ==================================================================== -->
598
599 <xsl:template match="d:caption">
600   <fo:block>
601     <xsl:if test="@align = 'right' or @align = 'left' or @align='center'">
602       <xsl:attribute name="text-align"><xsl:value-of
603                          select="@align"/></xsl:attribute>
604     </xsl:if>
605     <xsl:apply-templates/>
606   </fo:block>
607 </xsl:template>
608
609 <!-- ==================================================================== -->
610
611 <xsl:template name="fo-external-image">
612   <xsl:param name="filename"/>
613
614   <xsl:choose>
615     <xsl:when test="$passivetex.extensions != 0
616                     or $fop.extensions != 0">
617       <xsl:value-of select="$filename"/>
618     </xsl:when>
619     <xsl:otherwise>
620       <xsl:value-of select="concat('url(', $filename, ')')"/>
621     </xsl:otherwise>
622   </xsl:choose>
623 </xsl:template>
624
625 <!-- Resolve xml:base attributes -->
626 <xsl:template match="@fileref">
627   <!-- need a check for absolute urls -->
628   <xsl:choose>
629     <xsl:when test="contains(., ':') or starts-with(.,'/')">
630       <!-- it has a uri scheme or starts with '/', so it is an absolute uri -->
631       <xsl:value-of select="."/>
632     </xsl:when>
633     <xsl:when test="$keep.relative.image.uris != 0">
634       <!-- leave it alone -->
635       <xsl:value-of select="."/>
636     </xsl:when>
637     <xsl:otherwise>
638       <!-- its a relative uri -->
639       <xsl:call-template name="relative-uri">
640       </xsl:call-template>
641     </xsl:otherwise>
642   </xsl:choose>
643 </xsl:template>
644
645 </xsl:stylesheet>