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