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 9647 2012-10-26 17:42:03Z bobstayton $
|
---|
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="$fop1.extensions != 0">
|
---|
37 | <xsl:text> BMP GIF TIFF SVG PNG EPS JPG JPEG linespecific </xsl:text>
|
---|
38 | </xsl:when>
|
---|
39 | <xsl:when test="$fop.extensions != 0">
|
---|
40 | <xsl:text> BMP GIF TIFF SVG PNG EPS JPG JPEG linespecific </xsl:text>
|
---|
41 | </xsl:when>
|
---|
42 | <xsl:when test="$arbortext.extensions != 0">
|
---|
43 | <xsl:text> PNG PDF JPG JPEG linespecific GIF GIF87a GIF89a TIFF BMP </xsl:text>
|
---|
44 | </xsl:when>
|
---|
45 | <xsl:when test="$xep.extensions != 0">
|
---|
46 | <xsl:text> SVG PNG PDF JPG JPEG linespecific GIF GIF87a GIF89a TIFF BMP </xsl:text>
|
---|
47 | </xsl:when>
|
---|
48 | <xsl:otherwise>
|
---|
49 | <xsl:text> PNG PDF JPG JPEG linespecific GIF GIF87a GIF89a TIFF BMP </xsl:text>
|
---|
50 | </xsl:otherwise>
|
---|
51 | </xsl:choose>
|
---|
52 | </xsl:param>
|
---|
53 |
|
---|
54 | <xsl:template name="is.graphic.format">
|
---|
55 | <xsl:param name="format"/>
|
---|
56 | <xsl:if test="contains($graphic.notations, concat(' ',$format,' '))">1</xsl:if>
|
---|
57 | </xsl:template>
|
---|
58 |
|
---|
59 | <xsl:param name="graphic.extensions">
|
---|
60 | <!-- n.b. exactly one leading space, one trailing space, and one inter-word space -->
|
---|
61 | <xsl:choose>
|
---|
62 | <xsl:when test="$fop1.extensions != 0">
|
---|
63 | <xsl:text> bmp gif tif tiff svg png pdf jpg jpeg eps </xsl:text>
|
---|
64 | </xsl:when>
|
---|
65 | <xsl:when test="$fop.extensions != 0">
|
---|
66 | <xsl:text> bmp gif tif tiff svg png pdf jpg jpeg eps </xsl:text>
|
---|
67 | </xsl:when>
|
---|
68 | <xsl:when test="$arbortext.extensions != 0">
|
---|
69 | <xsl:text> png pdf jpg jpeg gif tif tiff bmp </xsl:text>
|
---|
70 | </xsl:when>
|
---|
71 | <xsl:when test="$xep.extensions != 0">
|
---|
72 | <xsl:text> svg png pdf jpg jpeg gif tif tiff bmp eps </xsl:text>
|
---|
73 | </xsl:when>
|
---|
74 | <xsl:otherwise>
|
---|
75 | <xsl:text> svg png pdf jpg jpeg gif tif tiff bmp eps </xsl:text>
|
---|
76 | </xsl:otherwise>
|
---|
77 | </xsl:choose>
|
---|
78 | </xsl:param>
|
---|
79 |
|
---|
80 | <xsl:template name="is.graphic.extension">
|
---|
81 | <xsl:param name="ext"/>
|
---|
82 | <xsl:variable name="lcext" select="translate($ext,
|
---|
83 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
---|
84 | 'abcdefghijklmnopqrstuvwxyz')"/>
|
---|
85 |
|
---|
86 | <xsl:if test="contains($graphic.extensions,
|
---|
87 | concat(' ', $lcext, ' '))">1</xsl:if>
|
---|
88 | </xsl:template>
|
---|
89 |
|
---|
90 |
|
---|
91 | <!-- ==================================================================== -->
|
---|
92 |
|
---|
93 | <xsl:template match="screenshot">
|
---|
94 | <fo:block>
|
---|
95 | <xsl:call-template name="anchor"/>
|
---|
96 | <xsl:apply-templates/>
|
---|
97 | </fo:block>
|
---|
98 | </xsl:template>
|
---|
99 |
|
---|
100 | <xsl:template match="screenshot/title">
|
---|
101 | <xsl:call-template name="formal.object.heading">
|
---|
102 | <xsl:with-param name="object" select=".."/>
|
---|
103 | </xsl:call-template>
|
---|
104 | </xsl:template>
|
---|
105 |
|
---|
106 | <xsl:template match="screeninfo">
|
---|
107 | </xsl:template>
|
---|
108 |
|
---|
109 | <!-- ==================================================================== -->
|
---|
110 | <!-- Override these templates for FO -->
|
---|
111 | <!-- ==================================================================== -->
|
---|
112 |
|
---|
113 | <xsl:template name="image.scalefit">
|
---|
114 | <xsl:choose>
|
---|
115 | <xsl:when test="$ignore.image.scaling != 0">0</xsl:when>
|
---|
116 | <xsl:when test="@contentwidth">0</xsl:when>
|
---|
117 | <xsl:when test="@contentdepth and
|
---|
118 | @contentdepth != '100%'">0</xsl:when>
|
---|
119 | <xsl:when test="@scale">0</xsl:when>
|
---|
120 | <xsl:when test="@scalefit"><xsl:value-of select="@scalefit"/></xsl:when>
|
---|
121 | <xsl:when test="@width or @depth">1</xsl:when>
|
---|
122 | <xsl:when test="$default.image.width != ''">1</xsl:when>
|
---|
123 | <xsl:otherwise>0</xsl:otherwise>
|
---|
124 | </xsl:choose>
|
---|
125 | </xsl:template>
|
---|
126 |
|
---|
127 | <xsl:template name="image.scale">
|
---|
128 | <xsl:choose>
|
---|
129 | <xsl:when test="$ignore.image.scaling != 0">0</xsl:when>
|
---|
130 | <xsl:when test="@contentwidth or @contentdepth">1.0</xsl:when>
|
---|
131 | <xsl:when test="@scale">
|
---|
132 | <xsl:value-of select="@scale div 100.0"/>
|
---|
133 | </xsl:when>
|
---|
134 | <xsl:otherwise>1.0</xsl:otherwise>
|
---|
135 | </xsl:choose>
|
---|
136 | </xsl:template>
|
---|
137 |
|
---|
138 | <xsl:template name="image.filename">
|
---|
139 | <xsl:choose>
|
---|
140 | <xsl:when test="svg:*" xmlns:svg="http://www.w3.org/2000/svg">
|
---|
141 | <!-- no filename for inline SVG content -->
|
---|
142 | </xsl:when>
|
---|
143 | <xsl:when test="mml:*" xmlns:mml="http://www.w3.org/1998/Math/MathML">
|
---|
144 | <!-- no filename for inline MathML content -->
|
---|
145 | </xsl:when>
|
---|
146 | <xsl:when test="local-name(.) = 'graphic'
|
---|
147 | or local-name(.) = 'inlinegraphic'">
|
---|
148 | <!-- handle legacy graphic and inlinegraphic by new template -->
|
---|
149 | <xsl:call-template name="mediaobject.filename">
|
---|
150 | <xsl:with-param name="object" select="."/>
|
---|
151 | </xsl:call-template>
|
---|
152 | </xsl:when>
|
---|
153 | <xsl:otherwise>
|
---|
154 | <!-- imagedata, videodata, audiodata -->
|
---|
155 | <xsl:call-template name="mediaobject.filename">
|
---|
156 | <xsl:with-param name="object" select=".."/>
|
---|
157 | </xsl:call-template>
|
---|
158 | </xsl:otherwise>
|
---|
159 | </xsl:choose>
|
---|
160 | </xsl:template>
|
---|
161 |
|
---|
162 | <xsl:template name="image.src">
|
---|
163 | <xsl:param name="filename"/>
|
---|
164 |
|
---|
165 | <xsl:choose>
|
---|
166 | <xsl:when test="svg:*" xmlns:svg="http://www.w3.org/2000/svg">
|
---|
167 | <!-- no src attribute for inline SVG content -->
|
---|
168 | </xsl:when>
|
---|
169 | <xsl:when test="mml:*" xmlns:mml="http://www.w3.org/1998/Math/MathML">
|
---|
170 | <!-- no src attribute for inline MathML content -->
|
---|
171 | </xsl:when>
|
---|
172 | <xsl:otherwise>
|
---|
173 | <xsl:call-template name="fo-external-image">
|
---|
174 | <xsl:with-param name="filename">
|
---|
175 | <xsl:if test="$img.src.path != '' and
|
---|
176 | not(starts-with($filename, '/')) and
|
---|
177 | not(contains($filename, '://'))">
|
---|
178 | <xsl:value-of select="$img.src.path"/>
|
---|
179 | </xsl:if>
|
---|
180 | <xsl:value-of select="$filename"/>
|
---|
181 | </xsl:with-param>
|
---|
182 | </xsl:call-template>
|
---|
183 | </xsl:otherwise>
|
---|
184 | </xsl:choose>
|
---|
185 | </xsl:template>
|
---|
186 |
|
---|
187 | <xsl:template name="image.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:template>
|
---|
194 |
|
---|
195 | <xsl:template name="image.bgcolor">
|
---|
196 | <xsl:call-template name="pi.dbfo_background-color">
|
---|
197 | <xsl:with-param name="node" select=".."/>
|
---|
198 | </xsl:call-template>
|
---|
199 | </xsl:template>
|
---|
200 |
|
---|
201 | <xsl:template name="image.width">
|
---|
202 | <xsl:choose>
|
---|
203 | <xsl:when test="$ignore.image.scaling != 0">auto</xsl:when>
|
---|
204 | <xsl:when test="contains(@width,'%')">
|
---|
205 | <xsl:value-of select="@width"/>
|
---|
206 | </xsl:when>
|
---|
207 | <xsl:when test="@width and not(@width = '')">
|
---|
208 | <xsl:call-template name="length-spec">
|
---|
209 | <xsl:with-param name="length" select="@width"/>
|
---|
210 | <xsl:with-param name="default.units" select="'px'"/>
|
---|
211 | </xsl:call-template>
|
---|
212 | </xsl:when>
|
---|
213 | <xsl:when test="not(@depth) and $default.image.width != ''">
|
---|
214 | <xsl:call-template name="length-spec">
|
---|
215 | <xsl:with-param name="length" select="$default.image.width"/>
|
---|
216 | <xsl:with-param name="default.units" select="'px'"/>
|
---|
217 | </xsl:call-template>
|
---|
218 | </xsl:when>
|
---|
219 | <xsl:otherwise>auto</xsl:otherwise>
|
---|
220 | </xsl:choose>
|
---|
221 | </xsl:template>
|
---|
222 |
|
---|
223 | <xsl:template name="image.height">
|
---|
224 | <xsl:choose>
|
---|
225 | <xsl:when test="$ignore.image.scaling != 0">auto</xsl:when>
|
---|
226 | <xsl:when test="contains(@depth,'%')">
|
---|
227 | <xsl:value-of select="@depth"/>
|
---|
228 | </xsl:when>
|
---|
229 | <xsl:when test="@depth">
|
---|
230 | <xsl:call-template name="length-spec">
|
---|
231 | <xsl:with-param name="length" select="@depth"/>
|
---|
232 | <xsl:with-param name="default.units" select="'px'"/>
|
---|
233 | </xsl:call-template>
|
---|
234 | </xsl:when>
|
---|
235 | <xsl:otherwise>auto</xsl:otherwise>
|
---|
236 | </xsl:choose>
|
---|
237 | </xsl:template>
|
---|
238 |
|
---|
239 | <xsl:template name="image.content.width">
|
---|
240 | <xsl:param name="scalefit" select="0"/>
|
---|
241 | <xsl:param name="scale" select="'1.0'"/>
|
---|
242 |
|
---|
243 | <xsl:choose>
|
---|
244 | <xsl:when test="$ignore.image.scaling != 0">auto</xsl:when>
|
---|
245 | <xsl:when test="contains(@contentwidth,'%')">
|
---|
246 | <xsl:value-of select="@contentwidth"/>
|
---|
247 | </xsl:when>
|
---|
248 | <xsl:when test="@contentwidth">
|
---|
249 | <xsl:call-template name="length-spec">
|
---|
250 | <xsl:with-param name="length" select="@contentwidth"/>
|
---|
251 | <xsl:with-param name="default.units" select="'px'"/>
|
---|
252 | </xsl:call-template>
|
---|
253 | </xsl:when>
|
---|
254 | <xsl:when test="number($scale) != 1.0">
|
---|
255 | <xsl:value-of select="$scale * 100"/>
|
---|
256 | <xsl:text>%</xsl:text>
|
---|
257 | </xsl:when>
|
---|
258 | <xsl:when test="$scalefit = 1">scale-to-fit</xsl:when>
|
---|
259 | <xsl:otherwise>auto</xsl:otherwise>
|
---|
260 | </xsl:choose>
|
---|
261 | </xsl:template>
|
---|
262 |
|
---|
263 | <xsl:template name="image.content.height">
|
---|
264 | <xsl:param name="scalefit" select="0"/>
|
---|
265 | <xsl:param name="scale" select="0"/>
|
---|
266 |
|
---|
267 | <xsl:choose>
|
---|
268 | <xsl:when test="$ignore.image.scaling != 0">auto</xsl:when>
|
---|
269 | <xsl:when test="contains(@contentdepth,'%')">
|
---|
270 | <xsl:value-of select="@contentdepth"/>
|
---|
271 | </xsl:when>
|
---|
272 | <xsl:when test="@contentdepth">
|
---|
273 | <xsl:call-template name="length-spec">
|
---|
274 | <xsl:with-param name="length" select="@contentdepth"/>
|
---|
275 | <xsl:with-param name="default.units" select="'px'"/>
|
---|
276 | </xsl:call-template>
|
---|
277 | </xsl:when>
|
---|
278 | <xsl:when test="number($scale) != 1.0">
|
---|
279 | <xsl:value-of select="$scale * 100"/>
|
---|
280 | <xsl:text>%</xsl:text>
|
---|
281 | </xsl:when>
|
---|
282 | <xsl:when test="$scalefit = 1">scale-to-fit</xsl:when>
|
---|
283 | <xsl:otherwise>auto</xsl:otherwise>
|
---|
284 | </xsl:choose>
|
---|
285 | </xsl:template>
|
---|
286 |
|
---|
287 | <xsl:template name="image.align">
|
---|
288 | <xsl:value-of select="@align"/>
|
---|
289 | </xsl:template>
|
---|
290 |
|
---|
291 | <xsl:template name="image.valign">
|
---|
292 | <xsl:if test="@valign">
|
---|
293 | <xsl:choose>
|
---|
294 | <xsl:when test="ancestor::inlinemediaobject or ancestor-or-self::inlinegraphic">
|
---|
295 | <xsl:choose>
|
---|
296 | <xsl:when test="@valign = 'top'">baseline</xsl:when>
|
---|
297 | <xsl:when test="@valign = 'middle'">central</xsl:when>
|
---|
298 | <xsl:when test="@valign = 'bottom'">text-before-edge</xsl:when>
|
---|
299 | </xsl:choose>
|
---|
300 | </xsl:when>
|
---|
301 | <xsl:otherwise>
|
---|
302 | <xsl:choose>
|
---|
303 | <xsl:when test="@valign = 'top'">before</xsl:when>
|
---|
304 | <xsl:when test="@valign = 'middle'">center</xsl:when>
|
---|
305 | <xsl:when test="@valign = 'bottom'">after</xsl:when>
|
---|
306 | </xsl:choose>
|
---|
307 | </xsl:otherwise>
|
---|
308 | </xsl:choose>
|
---|
309 | </xsl:if>
|
---|
310 | </xsl:template>
|
---|
311 |
|
---|
312 |
|
---|
313 | <xsl:template name="process.image">
|
---|
314 | <!-- When this template is called, the current node should be -->
|
---|
315 | <!-- a graphic, inlinegraphic, imagedata, or videodata. All -->
|
---|
316 | <!-- those elements have the same set of attributes, so we can -->
|
---|
317 | <!-- handle them all in one place. -->
|
---|
318 |
|
---|
319 | <!-- Compute each attribute value with its own customizable template call -->
|
---|
320 | <xsl:variable name="scalefit">
|
---|
321 | <xsl:call-template name="image.scalefit"/>
|
---|
322 | </xsl:variable>
|
---|
323 |
|
---|
324 | <xsl:variable name="scale">
|
---|
325 | <xsl:call-template name="image.scale"/>
|
---|
326 | </xsl:variable>
|
---|
327 |
|
---|
328 | <xsl:variable name="filename">
|
---|
329 | <xsl:call-template name="image.filename"/>
|
---|
330 | </xsl:variable>
|
---|
331 |
|
---|
332 | <xsl:variable name="src">
|
---|
333 | <xsl:call-template name="image.src">
|
---|
334 | <xsl:with-param name="filename" select="$filename"/>
|
---|
335 | </xsl:call-template>
|
---|
336 | </xsl:variable>
|
---|
337 |
|
---|
338 | <xsl:variable name="content.type">
|
---|
339 | <xsl:call-template name="image.content.type"/>
|
---|
340 | </xsl:variable>
|
---|
341 |
|
---|
342 | <xsl:variable name="bgcolor">
|
---|
343 | <xsl:call-template name="image.bgcolor"/>
|
---|
344 | </xsl:variable>
|
---|
345 |
|
---|
346 | <xsl:variable name="width">
|
---|
347 | <xsl:call-template name="image.width"/>
|
---|
348 | </xsl:variable>
|
---|
349 |
|
---|
350 | <xsl:variable name="height">
|
---|
351 | <xsl:call-template name="image.height"/>
|
---|
352 | </xsl:variable>
|
---|
353 |
|
---|
354 | <xsl:variable name="content.width">
|
---|
355 | <xsl:call-template name="image.content.width">
|
---|
356 | <xsl:with-param name="scalefit" select="$scalefit"/>
|
---|
357 | <xsl:with-param name="scale" select="$scale"/>
|
---|
358 | </xsl:call-template>
|
---|
359 | </xsl:variable>
|
---|
360 |
|
---|
361 | <xsl:variable name="content.height">
|
---|
362 | <xsl:call-template name="image.content.height">
|
---|
363 | <xsl:with-param name="scalefit" select="$scalefit"/>
|
---|
364 | <xsl:with-param name="scale" select="$scale"/>
|
---|
365 | </xsl:call-template>
|
---|
366 | </xsl:variable>
|
---|
367 |
|
---|
368 | <xsl:variable name="align">
|
---|
369 | <xsl:call-template name="image.align"/>
|
---|
370 | </xsl:variable>
|
---|
371 |
|
---|
372 | <xsl:variable name="valign">
|
---|
373 | <xsl:call-template name="image.valign"/>
|
---|
374 | </xsl:variable>
|
---|
375 |
|
---|
376 | <xsl:variable name="element.name">
|
---|
377 | <xsl:choose>
|
---|
378 | <xsl:when test="svg:*" xmlns:svg="http://www.w3.org/2000/svg">
|
---|
379 | <xsl:text>fo:instream-foreign-object</xsl:text>
|
---|
380 | </xsl:when>
|
---|
381 | <xsl:when test="mml:*" xmlns:mml="http://www.w3.org/1998/Math/MathML">
|
---|
382 | <xsl:text>fo:instream-foreign-object</xsl:text>
|
---|
383 | </xsl:when>
|
---|
384 | <xsl:otherwise>
|
---|
385 | <xsl:text>fo:external-graphic</xsl:text>
|
---|
386 | </xsl:otherwise>
|
---|
387 | </xsl:choose>
|
---|
388 | </xsl:variable>
|
---|
389 |
|
---|
390 | <xsl:element name="{$element.name}">
|
---|
391 |
|
---|
392 | <xsl:if test="$src != ''">
|
---|
393 | <xsl:attribute name="src">
|
---|
394 | <xsl:value-of select="$src"/>
|
---|
395 | </xsl:attribute>
|
---|
396 | </xsl:if>
|
---|
397 |
|
---|
398 | <xsl:if test="$width != ''">
|
---|
399 | <xsl:attribute name="width">
|
---|
400 | <xsl:value-of select="$width"/>
|
---|
401 | </xsl:attribute>
|
---|
402 | </xsl:if>
|
---|
403 |
|
---|
404 | <xsl:if test="$height != ''">
|
---|
405 | <xsl:attribute name="height">
|
---|
406 | <xsl:value-of select="$height"/>
|
---|
407 | </xsl:attribute>
|
---|
408 | </xsl:if>
|
---|
409 |
|
---|
410 | <xsl:if test="$content.width != ''">
|
---|
411 | <xsl:attribute name="content-width">
|
---|
412 | <xsl:value-of select="$content.width"/>
|
---|
413 | </xsl:attribute>
|
---|
414 | </xsl:if>
|
---|
415 |
|
---|
416 | <xsl:if test="$content.height != ''">
|
---|
417 | <xsl:attribute name="content-height">
|
---|
418 | <xsl:value-of select="$content.height"/>
|
---|
419 | </xsl:attribute>
|
---|
420 | </xsl:if>
|
---|
421 |
|
---|
422 | <xsl:if test="$content.type != ''">
|
---|
423 | <xsl:attribute name="content-type">
|
---|
424 | <xsl:value-of select="concat('content-type:',$content.type)"/>
|
---|
425 | </xsl:attribute>
|
---|
426 | </xsl:if>
|
---|
427 |
|
---|
428 | <xsl:if test="$bgcolor != ''">
|
---|
429 | <xsl:attribute name="background-color">
|
---|
430 | <xsl:value-of select="$bgcolor"/>
|
---|
431 | </xsl:attribute>
|
---|
432 | </xsl:if>
|
---|
433 |
|
---|
434 | <xsl:if test="$align != ''">
|
---|
435 | <xsl:attribute name="text-align">
|
---|
436 | <xsl:value-of select="$align"/>
|
---|
437 | </xsl:attribute>
|
---|
438 | </xsl:if>
|
---|
439 |
|
---|
440 | <xsl:if test="$valign != ''">
|
---|
441 | <xsl:variable name="att.name">
|
---|
442 | <xsl:choose>
|
---|
443 | <xsl:when test="ancestor::inlinemediaobject or ancestor-or-self::inlinegraphic">
|
---|
444 | <xsl:text>alignment-baseline</xsl:text>
|
---|
445 | </xsl:when>
|
---|
446 | <xsl:otherwise>
|
---|
447 | <xsl:text>display-align</xsl:text>
|
---|
448 | </xsl:otherwise>
|
---|
449 | </xsl:choose>
|
---|
450 | </xsl:variable>
|
---|
451 | <xsl:attribute name="{$att.name}">
|
---|
452 | <xsl:value-of select="$valign"/>
|
---|
453 | </xsl:attribute>
|
---|
454 | </xsl:if>
|
---|
455 |
|
---|
456 | <!-- copy literal SVG elements to output -->
|
---|
457 | <xsl:if test="svg:*" xmlns:svg="http://www.w3.org/2000/svg">
|
---|
458 | <xsl:call-template name="process.svg"/>
|
---|
459 | </xsl:if>
|
---|
460 |
|
---|
461 | <xsl:if test="mml:*" xmlns:mml="http://www.w3.org/1998/Math/MathML">
|
---|
462 | <xsl:call-template name="process.mml"/>
|
---|
463 | </xsl:if>
|
---|
464 |
|
---|
465 | </xsl:element>
|
---|
466 | </xsl:template>
|
---|
467 |
|
---|
468 | <!-- ==================================================================== -->
|
---|
469 |
|
---|
470 | <xsl:template match="graphic">
|
---|
471 | <xsl:choose>
|
---|
472 | <xsl:when test="parent::inlineequation">
|
---|
473 | <xsl:call-template name="process.image"/>
|
---|
474 | </xsl:when>
|
---|
475 | <xsl:otherwise>
|
---|
476 | <fo:block>
|
---|
477 | <xsl:call-template name="anchor"/>
|
---|
478 | <xsl:if test="@align">
|
---|
479 | <xsl:attribute name="text-align">
|
---|
480 | <xsl:value-of select="@align"/>
|
---|
481 | </xsl:attribute>
|
---|
482 | </xsl:if>
|
---|
483 | <xsl:call-template name="process.image"/>
|
---|
484 | </fo:block>
|
---|
485 | </xsl:otherwise>
|
---|
486 | </xsl:choose>
|
---|
487 | </xsl:template>
|
---|
488 |
|
---|
489 | <xsl:template match="inlinegraphic">
|
---|
490 | <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
|
---|
491 | <xsl:variable name="filename">
|
---|
492 | <xsl:choose>
|
---|
493 | <xsl:when test="@entityref">
|
---|
494 | <xsl:value-of select="unparsed-entity-uri(@entityref)"/>
|
---|
495 | </xsl:when>
|
---|
496 | <xsl:otherwise>
|
---|
497 | <xsl:apply-templates select="@fileref"/>
|
---|
498 | </xsl:otherwise>
|
---|
499 | </xsl:choose>
|
---|
500 | </xsl:variable>
|
---|
501 |
|
---|
502 | <xsl:choose>
|
---|
503 | <xsl:when test="@format='linespecific'">
|
---|
504 | <xsl:choose>
|
---|
505 | <xsl:when test="$use.extensions != '0'
|
---|
506 | and $textinsert.extension != '0'">
|
---|
507 | <xsl:choose>
|
---|
508 | <xsl:when test="contains($vendor, 'SAXON')">
|
---|
509 | <stext:insertfile href="{$filename}" encoding="{$textdata.default.encoding}"/>
|
---|
510 | </xsl:when>
|
---|
511 | <xsl:when test="contains($vendor, 'Apache Software Foundation')">
|
---|
512 | <xtext:insertfile href="{$filename}"/>
|
---|
513 | </xsl:when>
|
---|
514 | <xsl:otherwise>
|
---|
515 | <xsl:message terminate="yes">
|
---|
516 | <xsl:text>Don't know how to insert files with </xsl:text>
|
---|
517 | <xsl:value-of select="$vendor"/>
|
---|
518 | </xsl:message>
|
---|
519 | </xsl:otherwise>
|
---|
520 | </xsl:choose>
|
---|
521 | </xsl:when>
|
---|
522 | <xsl:otherwise>
|
---|
523 | <xsl:message terminate="yes">
|
---|
524 | <xsl:text>Cannot insert </xsl:text><xsl:value-of select="$filename"/>
|
---|
525 | <xsl:text>. Check use.extensions and textinsert.extension parameters.</xsl:text>
|
---|
526 | </xsl:message>
|
---|
527 | </xsl:otherwise>
|
---|
528 | </xsl:choose>
|
---|
529 | </xsl:when>
|
---|
530 | <xsl:otherwise>
|
---|
531 | <xsl:call-template name="process.image"/>
|
---|
532 | </xsl:otherwise>
|
---|
533 | </xsl:choose>
|
---|
534 | </xsl:template>
|
---|
535 |
|
---|
536 | <!-- ==================================================================== -->
|
---|
537 |
|
---|
538 | <xsl:template match="mediaobject|mediaobjectco">
|
---|
539 |
|
---|
540 | <xsl:variable name="olist" select="imageobject|imageobjectco
|
---|
541 | |videoobject|audioobject
|
---|
542 | |textobject"/>
|
---|
543 |
|
---|
544 | <xsl:variable name="object.index">
|
---|
545 | <xsl:call-template name="select.mediaobject.index">
|
---|
546 | <xsl:with-param name="olist" select="$olist"/>
|
---|
547 | <xsl:with-param name="count" select="1"/>
|
---|
548 | </xsl:call-template>
|
---|
549 | </xsl:variable>
|
---|
550 |
|
---|
551 | <xsl:variable name="object" select="$olist[position() = $object.index]"/>
|
---|
552 |
|
---|
553 | <xsl:variable name="align">
|
---|
554 | <xsl:value-of select="$object/descendant::imagedata[@align][1]/@align"/>
|
---|
555 | </xsl:variable>
|
---|
556 |
|
---|
557 | <xsl:variable name="id">
|
---|
558 | <xsl:call-template name="object.id"/>
|
---|
559 | </xsl:variable>
|
---|
560 |
|
---|
561 | <fo:block id="{$id}">
|
---|
562 | <xsl:if test="$align != '' ">
|
---|
563 | <xsl:attribute name="text-align">
|
---|
564 | <xsl:value-of select="$align"/>
|
---|
565 | </xsl:attribute>
|
---|
566 | </xsl:if>
|
---|
567 |
|
---|
568 | <xsl:apply-templates select="$object"/>
|
---|
569 | <xsl:apply-templates select="caption"/>
|
---|
570 | </fo:block>
|
---|
571 | </xsl:template>
|
---|
572 |
|
---|
573 | <xsl:template match="inlinemediaobject">
|
---|
574 | <xsl:call-template name="select.mediaobject"/>
|
---|
575 | </xsl:template>
|
---|
576 |
|
---|
577 | <!-- ==================================================================== -->
|
---|
578 |
|
---|
579 | <xsl:template match="imageobjectco">
|
---|
580 | <xsl:choose>
|
---|
581 | <!-- select one imageobject? -->
|
---|
582 | <xsl:when test="$use.role.for.mediaobject != 0 and
|
---|
583 | count(imageobject) > 1 and
|
---|
584 | imageobject[@role]">
|
---|
585 | <xsl:variable name="olist" select="imageobject"/>
|
---|
586 |
|
---|
587 | <xsl:variable name="object.index">
|
---|
588 | <xsl:call-template name="select.mediaobject.index">
|
---|
589 | <xsl:with-param name="olist" select="$olist"/>
|
---|
590 | <xsl:with-param name="count" select="1"/>
|
---|
591 | </xsl:call-template>
|
---|
592 | </xsl:variable>
|
---|
593 |
|
---|
594 | <xsl:variable name="object" select="$olist[position() = $object.index]"/>
|
---|
595 |
|
---|
596 | <xsl:apply-templates select="$object"/>
|
---|
597 | </xsl:when>
|
---|
598 | <xsl:otherwise>
|
---|
599 | <!-- otherwise process them all -->
|
---|
600 | <xsl:apply-templates select="imageobject"/>
|
---|
601 | </xsl:otherwise>
|
---|
602 | </xsl:choose>
|
---|
603 |
|
---|
604 | <xsl:apply-templates select="calloutlist"/>
|
---|
605 |
|
---|
606 | </xsl:template>
|
---|
607 |
|
---|
608 | <xsl:template match="imageobject">
|
---|
609 | <xsl:choose>
|
---|
610 | <xsl:when test="imagedata">
|
---|
611 | <xsl:apply-templates select="imagedata"/>
|
---|
612 | </xsl:when>
|
---|
613 | <xsl:otherwise>
|
---|
614 | <fo:instream-foreign-object>
|
---|
615 | <xsl:apply-templates mode="copy-all"/>
|
---|
616 | </fo:instream-foreign-object>
|
---|
617 | </xsl:otherwise>
|
---|
618 | </xsl:choose>
|
---|
619 | </xsl:template>
|
---|
620 |
|
---|
621 | <!-- ==================================================================== -->
|
---|
622 |
|
---|
623 | <xsl:template match="*" mode="copy-all">
|
---|
624 | <xsl:copy>
|
---|
625 | <xsl:for-each select="@*">
|
---|
626 | <xsl:copy/>
|
---|
627 | </xsl:for-each>
|
---|
628 | <xsl:apply-templates mode="copy-all"/>
|
---|
629 | </xsl:copy>
|
---|
630 | </xsl:template>
|
---|
631 |
|
---|
632 | <xsl:template match="text()|comment()|processing-instruction()" mode="copy-all">
|
---|
633 | <xsl:copy/>
|
---|
634 | </xsl:template>
|
---|
635 |
|
---|
636 | <xsl:template name="process.mml">
|
---|
637 | <xsl:apply-templates mode="copy-all" select="*"/>
|
---|
638 | </xsl:template>
|
---|
639 |
|
---|
640 | <xsl:template name="process.svg">
|
---|
641 | <xsl:apply-templates mode="copy-all" select="*"/>
|
---|
642 | </xsl:template>
|
---|
643 |
|
---|
644 | <!-- ==================================================================== -->
|
---|
645 |
|
---|
646 | <xsl:template match="imagedata">
|
---|
647 | <xsl:choose>
|
---|
648 | <xsl:when test="@format='linespecific'">
|
---|
649 | <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
|
---|
650 |
|
---|
651 | <xsl:variable name="filename">
|
---|
652 | <xsl:call-template name="mediaobject.filename">
|
---|
653 | <xsl:with-param name="object" select=".."/>
|
---|
654 | </xsl:call-template>
|
---|
655 | </xsl:variable>
|
---|
656 |
|
---|
657 | <xsl:choose>
|
---|
658 | <xsl:when test="$use.extensions != '0'
|
---|
659 | and $textinsert.extension != '0'">
|
---|
660 | <xsl:choose>
|
---|
661 | <xsl:when test="contains($vendor, 'SAXON')">
|
---|
662 | <stext:insertfile href="{$filename}" encoding="{$textdata.default.encoding}"/>
|
---|
663 | </xsl:when>
|
---|
664 | <xsl:when test="contains($vendor, 'Apache Software Foundation')">
|
---|
665 | <xtext:insertfile href="{$filename}"/>
|
---|
666 | </xsl:when>
|
---|
667 | <xsl:otherwise>
|
---|
668 | <xsl:message terminate="yes">
|
---|
669 | <xsl:text>Don't know how to insert files with </xsl:text>
|
---|
670 | <xsl:value-of select="$vendor"/>
|
---|
671 | </xsl:message>
|
---|
672 | </xsl:otherwise>
|
---|
673 | </xsl:choose>
|
---|
674 | </xsl:when>
|
---|
675 | <xsl:otherwise>
|
---|
676 | <xsl:message terminate="yes">
|
---|
677 | <xsl:text>Cannot insert </xsl:text><xsl:value-of select="$filename"/>
|
---|
678 | <xsl:text>. Check use.extensions and textinsert.extension parameters.</xsl:text>
|
---|
679 | </xsl:message>
|
---|
680 | </xsl:otherwise>
|
---|
681 | </xsl:choose>
|
---|
682 | </xsl:when>
|
---|
683 | <xsl:otherwise>
|
---|
684 | <xsl:call-template name="process.image"/>
|
---|
685 | </xsl:otherwise>
|
---|
686 | </xsl:choose>
|
---|
687 | </xsl:template>
|
---|
688 |
|
---|
689 | <!-- ==================================================================== -->
|
---|
690 |
|
---|
691 | <xsl:template match="videoobject">
|
---|
692 | <xsl:apply-templates select="videodata"/>
|
---|
693 | </xsl:template>
|
---|
694 |
|
---|
695 | <xsl:template match="videodata">
|
---|
696 | <xsl:call-template name="process.image"/>
|
---|
697 | </xsl:template>
|
---|
698 |
|
---|
699 | <!-- ==================================================================== -->
|
---|
700 |
|
---|
701 | <xsl:template match="audioobject">
|
---|
702 | <xsl:apply-templates select="audiodata"/>
|
---|
703 | </xsl:template>
|
---|
704 |
|
---|
705 | <xsl:template match="audiodata">
|
---|
706 | <xsl:call-template name="process.image"/>
|
---|
707 | </xsl:template>
|
---|
708 |
|
---|
709 | <!-- ==================================================================== -->
|
---|
710 |
|
---|
711 | <xsl:template match="textobject">
|
---|
712 | <xsl:apply-templates/>
|
---|
713 | </xsl:template>
|
---|
714 |
|
---|
715 | <xsl:template match="textdata">
|
---|
716 | <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
|
---|
717 | <xsl:variable name="filename">
|
---|
718 | <xsl:choose>
|
---|
719 | <xsl:when test="@entityref">
|
---|
720 | <xsl:value-of select="unparsed-entity-uri(@entityref)"/>
|
---|
721 | </xsl:when>
|
---|
722 | <xsl:otherwise>
|
---|
723 | <xsl:apply-templates select="@fileref"/>
|
---|
724 | </xsl:otherwise>
|
---|
725 | </xsl:choose>
|
---|
726 | </xsl:variable>
|
---|
727 |
|
---|
728 | <xsl:variable name="encoding">
|
---|
729 | <xsl:choose>
|
---|
730 | <xsl:when test="@encoding">
|
---|
731 | <xsl:value-of select="@encoding"/>
|
---|
732 | </xsl:when>
|
---|
733 | <xsl:otherwise>
|
---|
734 | <xsl:value-of select="$textdata.default.encoding"/>
|
---|
735 | </xsl:otherwise>
|
---|
736 | </xsl:choose>
|
---|
737 | </xsl:variable>
|
---|
738 |
|
---|
739 | <xsl:choose>
|
---|
740 | <xsl:when test="$use.extensions != '0'
|
---|
741 | and $textinsert.extension != '0'">
|
---|
742 | <xsl:choose>
|
---|
743 | <xsl:when test="element-available('stext:insertfile')">
|
---|
744 | <stext:insertfile href="{$filename}" encoding="{$encoding}"/>
|
---|
745 | </xsl:when>
|
---|
746 | <xsl:when test="element-available('xtext:insertfile')">
|
---|
747 | <xtext:insertfile href="{$filename}"/>
|
---|
748 | </xsl:when>
|
---|
749 | <xsl:otherwise>
|
---|
750 | <xsl:message terminate="yes">
|
---|
751 | <xsl:text>Don't know how to insert files with </xsl:text>
|
---|
752 | <xsl:value-of select="$vendor"/>
|
---|
753 | </xsl:message>
|
---|
754 | </xsl:otherwise>
|
---|
755 | </xsl:choose>
|
---|
756 | </xsl:when>
|
---|
757 | <xsl:otherwise>
|
---|
758 | <xsl:message terminate="yes">
|
---|
759 | <xsl:text>Cannot insert </xsl:text><xsl:value-of select="$filename"/>
|
---|
760 | <xsl:text>. Check use.extensions and textinsert.extension parameters.</xsl:text>
|
---|
761 | </xsl:message>
|
---|
762 | </xsl:otherwise>
|
---|
763 | </xsl:choose>
|
---|
764 | </xsl:template>
|
---|
765 |
|
---|
766 | <!-- ==================================================================== -->
|
---|
767 |
|
---|
768 | <xsl:template match="mediaobject/caption|figure/caption">
|
---|
769 | <fo:block>
|
---|
770 | <xsl:if test="@align = 'right' or @align = 'left' or @align='center'">
|
---|
771 | <xsl:attribute name="text-align"><xsl:value-of
|
---|
772 | select="@align"/></xsl:attribute>
|
---|
773 | </xsl:if>
|
---|
774 | <xsl:apply-templates/>
|
---|
775 | </fo:block>
|
---|
776 | </xsl:template>
|
---|
777 |
|
---|
778 | <!-- ==================================================================== -->
|
---|
779 |
|
---|
780 | <xsl:template name="fo-external-image">
|
---|
781 | <xsl:param name="filename"/>
|
---|
782 |
|
---|
783 | <xsl:choose>
|
---|
784 | <xsl:when test="$fop.extensions != 0">
|
---|
785 | <xsl:value-of select="$filename"/>
|
---|
786 | </xsl:when>
|
---|
787 | <xsl:otherwise>
|
---|
788 | <xsl:value-of select="concat('url(', $filename, ')')"/>
|
---|
789 | </xsl:otherwise>
|
---|
790 | </xsl:choose>
|
---|
791 | </xsl:template>
|
---|
792 |
|
---|
793 | <!-- Resolve xml:base attributes -->
|
---|
794 | <xsl:template match="@fileref">
|
---|
795 | <!-- need a check for absolute urls -->
|
---|
796 | <xsl:choose>
|
---|
797 | <xsl:when test="contains(., ':') or starts-with(.,'/')">
|
---|
798 | <!-- it has a uri scheme or starts with '/', so it is an absolute uri -->
|
---|
799 | <xsl:value-of select="."/>
|
---|
800 | </xsl:when>
|
---|
801 | <xsl:when test="$keep.relative.image.uris != 0">
|
---|
802 | <!-- leave it alone -->
|
---|
803 | <xsl:value-of select="."/>
|
---|
804 | </xsl:when>
|
---|
805 | <xsl:otherwise>
|
---|
806 | <!-- its a relative uri -->
|
---|
807 | <xsl:call-template name="relative-uri">
|
---|
808 | </xsl:call-template>
|
---|
809 | </xsl:otherwise>
|
---|
810 | </xsl:choose>
|
---|
811 | </xsl:template>
|
---|
812 |
|
---|
813 | </xsl:stylesheet>
|
---|