| 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 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
<xsl:param name="graphic.notations"> |
| 33 |
|
| 34 |
<xsl:choose> |
| 35 |
<xsl:when test="$fop1.extensions != 0"> |
| 36 |
<xsl:text> BMP GIF TIFF SVG PNG EPS JPG JPEG linespecific </xsl:text> |
| 37 |
</xsl:when> |
| 38 |
<xsl:when test="$fop.extensions != 0"> |
| 39 |
<xsl:text> BMP GIF TIFF SVG PNG EPS JPG JPEG linespecific </xsl:text> |
| 40 |
</xsl:when> |
| 41 |
<xsl:when test="$arbortext.extensions != 0"> |
| 42 |
<xsl:text> PNG PDF JPG JPEG linespecific GIF GIF87a GIF89a TIFF BMP </xsl:text> |
| 43 |
</xsl:when> |
| 44 |
<xsl:when test="$xep.extensions != 0"> |
| 45 |
<xsl:text> SVG PNG PDF JPG JPEG linespecific GIF GIF87a GIF89a TIFF BMP </xsl:text> |
| 46 |
</xsl:when> |
| 47 |
<xsl:otherwise> |
| 48 |
<xsl:text> PNG PDF JPG JPEG linespecific GIF GIF87a GIF89a TIFF BMP </xsl:text> |
| 49 |
</xsl:otherwise> |
| 50 |
</xsl:choose> |
| 51 |
</xsl:param> |
| 52 |
|
| 53 |
<xsl:template name="is.graphic.format"> |
| 54 |
<xsl:param name="format"/> |
| 55 |
<xsl:if test="contains($graphic.notations, concat(' ',$format,' '))">1</xsl:if> |
| 56 |
</xsl:template> |
| 57 |
|
| 58 |
<xsl:param name="graphic.extensions"> |
| 59 |
|
| 60 |
<xsl:choose> |
| 61 |
<xsl:when test="$fop1.extensions != 0"> |
| 62 |
<xsl:text> bmp gif tif tiff svg png pdf jpg jpeg eps </xsl:text> |
| 63 |
</xsl:when> |
| 64 |
<xsl:when test="$fop.extensions != 0"> |
| 65 |
<xsl:text> bmp gif tif tiff svg png pdf jpg jpeg eps </xsl:text> |
| 66 |
</xsl:when> |
| 67 |
<xsl:when test="$arbortext.extensions != 0"> |
| 68 |
<xsl:text> png pdf jpg jpeg gif tif tiff bmp </xsl:text> |
| 69 |
</xsl:when> |
| 70 |
<xsl:when test="$xep.extensions != 0"> |
| 71 |
<xsl:text> svg png pdf jpg jpeg gif tif tiff bmp eps </xsl:text> |
| 72 |
</xsl:when> |
| 73 |
<xsl:otherwise> |
| 74 |
<xsl:text> svg png pdf jpg jpeg gif tif tiff bmp eps </xsl:text> |
| 75 |
</xsl:otherwise> |
| 76 |
</xsl:choose> |
| 77 |
</xsl:param> |
| 78 |
|
| 79 |
<xsl:template name="is.graphic.extension"> |
| 80 |
<xsl:param name="ext"/> |
| 81 |
<xsl:variable name="lcext" select="translate($ext, |
| 82 |
'ABCDEFGHIJKLMNOPQRSTUVWXYZ', |
| 83 |
'abcdefghijklmnopqrstuvwxyz')"/> |
| 84 |
|
| 85 |
<xsl:if test="contains($graphic.extensions, |
| 86 |
concat(' ', $lcext, ' '))">1</xsl:if> |
| 87 |
</xsl:template> |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
<xsl:template match="d:screenshot"> |
| 93 |
<fo:block> |
| 94 |
<xsl:call-template name="anchor"/> |
| 95 |
<xsl:apply-templates/> |
| 96 |
</fo:block> |
| 97 |
</xsl:template> |
| 98 |
|
| 99 |
<xsl:template match="d:screenshot/d:title"> |
| 100 |
<xsl:call-template name="formal.object.heading"> |
| 101 |
<xsl:with-param name="object" select=".."/> |
| 102 |
</xsl:call-template> |
| 103 |
</xsl:template> |
| 104 |
|
| 105 |
<xsl:template match="d:screeninfo"> |
| 106 |
</xsl:template> |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
<xsl:template name="image.scalefit"> |
| 113 |
<xsl:choose> |
| 114 |
<xsl:when test="$ignore.image.scaling != 0">0</xsl:when> |
| 115 |
<xsl:when test="@contentwidth">0</xsl:when> |
| 116 |
<xsl:when test="@contentdepth and |
| 117 |
@contentdepth != '100%'">0</xsl:when> |
| 118 |
<xsl:when test="@scale">0</xsl:when> |
| 119 |
<xsl:when test="@scalefit"><xsl:value-of select="@scalefit"/></xsl:when> |
| 120 |
<xsl:when test="@width or @depth">1</xsl:when> |
| 121 |
<xsl:when test="$default.image.width != ''">1</xsl:when> |
| 122 |
<xsl:otherwise>0</xsl:otherwise> |
| 123 |
</xsl:choose> |
| 124 |
</xsl:template> |
| 125 |
|
| 126 |
<xsl:template name="image.scale"> |
| 127 |
<xsl:choose> |
| 128 |
<xsl:when test="$ignore.image.scaling != 0">0</xsl:when> |
| 129 |
<xsl:when test="@contentwidth or @contentdepth">1.0</xsl:when> |
| 130 |
<xsl:when test="@scale"> |
| 131 |
<xsl:value-of select="@scale div 100.0"/> |
| 132 |
</xsl:when> |
| 133 |
<xsl:otherwise>1.0</xsl:otherwise> |
| 134 |
</xsl:choose> |
| 135 |
</xsl:template> |
| 136 |
|
| 137 |
<xsl:template name="image.filename"> |
| 138 |
<xsl:choose> |
| 139 |
<xsl:when test="svg:*" xmlns:svg="http://www.w3.org/2000/svg"> |
| 140 |
|
| 141 |
</xsl:when> |
| 142 |
<xsl:when test="mml:*" xmlns:mml="http://www.w3.org/1998/Math/MathML"> |
| 143 |
|
| 144 |
</xsl:when> |
| 145 |
<xsl:when test="local-name(.) = 'graphic' |
| 146 |
or local-name(.) = 'inlinegraphic'"> |
| 147 |
|
| 148 |
<xsl:call-template name="mediaobject.filename"> |
| 149 |
<xsl:with-param name="object" select="."/> |
| 150 |
</xsl:call-template> |
| 151 |
</xsl:when> |
| 152 |
<xsl:otherwise> |
| 153 |
|
| 154 |
<xsl:call-template name="mediaobject.filename"> |
| 155 |
<xsl:with-param name="object" select=".."/> |
| 156 |
</xsl:call-template> |
| 157 |
</xsl:otherwise> |
| 158 |
</xsl:choose> |
| 159 |
</xsl:template> |
| 160 |
|
| 161 |
<xsl:template name="image.src"> |
| 162 |
<xsl:param name="filename"/> |
| 163 |
|
| 164 |
<xsl:choose> |
| 165 |
<xsl:when test="svg:*" xmlns:svg="http://www.w3.org/2000/svg"> |
| 166 |
|
| 167 |
</xsl:when> |
| 168 |
<xsl:when test="mml:*" xmlns:mml="http://www.w3.org/1998/Math/MathML"> |
| 169 |
|
| 170 |
</xsl:when> |
| 171 |
<xsl:otherwise> |
| 172 |
<xsl:call-template name="fo-external-image"> |
| 173 |
<xsl:with-param name="filename"> |
| 174 |
<xsl:if test="$img.src.path != '' and |
| 175 |
not(starts-with($filename, '/')) and |
| 176 |
not(starts-with($filename, 'file:/')) 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::d:inlinemediaobject or ancestor-or-self::d: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 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
|
| 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::d:inlinemediaobject or ancestor-or-self::d: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 |
|
| 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="d:graphic"> |
| 471 |
<xsl:choose> |
| 472 |
<xsl:when test="parent::d: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="d: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="d:mediaobject|d:mediaobjectco"> |
| 539 |
|
| 540 |
<xsl:variable name="olist" select="d:imageobject|d:imageobjectco |
| 541 |
|d:videoobject|d:audioobject |
| 542 |
|d: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::d: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="d:caption"/> |
| 570 |
</fo:block> |
| 571 |
</xsl:template> |
| 572 |
|
| 573 |
<xsl:template match="d:inlinemediaobject"> |
| 574 |
<xsl:call-template name="select.mediaobject"/> |
| 575 |
</xsl:template> |
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
<xsl:template match="d:imageobjectco"> |
| 580 |
<xsl:choose> |
| 581 |
|
| 582 |
<xsl:when test="$use.role.for.mediaobject != 0 and |
| 583 |
count(d:imageobject) > 1 and |
| 584 |
d:imageobject[@role]"> |
| 585 |
<xsl:variable name="olist" select="d: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 |
|
| 600 |
<xsl:apply-templates select="d:imageobject"/> |
| 601 |
</xsl:otherwise> |
| 602 |
</xsl:choose> |
| 603 |
|
| 604 |
<xsl:apply-templates select="d:calloutlist"/> |
| 605 |
|
| 606 |
</xsl:template> |
| 607 |
|
| 608 |
<xsl:template match="d:imageobject"> |
| 609 |
<xsl:choose> |
| 610 |
<xsl:when test="d:imagedata"> |
| 611 |
<xsl:apply-templates select="d: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="d: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="d:videoobject"> |
| 692 |
<xsl:apply-templates select="d:videodata"/> |
| 693 |
</xsl:template> |
| 694 |
|
| 695 |
<xsl:template match="d:videodata"> |
| 696 |
<xsl:call-template name="process.image"/> |
| 697 |
</xsl:template> |
| 698 |
|
| 699 |
|
| 700 |
|
| 701 |
<xsl:template match="d:audioobject"> |
| 702 |
<xsl:apply-templates select="d:audiodata"/> |
| 703 |
</xsl:template> |
| 704 |
|
| 705 |
<xsl:template match="d:audiodata"> |
| 706 |
<xsl:call-template name="process.image"/> |
| 707 |
</xsl:template> |
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
<xsl:template match="d:textobject"> |
| 712 |
<xsl:apply-templates/> |
| 713 |
</xsl:template> |
| 714 |
|
| 715 |
<xsl:template match="d: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="d:mediaobject/d:caption|d:figure/d: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 |
|
| 794 |
<xsl:template match="@fileref"> |
| 795 |
|
| 796 |
<xsl:choose> |
| 797 |
<xsl:when test="contains(., ':') or starts-with(.,'/')"> |
| 798 |
|
| 799 |
<xsl:value-of select="."/> |
| 800 |
</xsl:when> |
| 801 |
<xsl:when test="$keep.relative.image.uris != 0"> |
| 802 |
|
| 803 |
<xsl:value-of select="."/> |
| 804 |
</xsl:when> |
| 805 |
<xsl:otherwise> |
| 806 |
|
| 807 |
<xsl:call-template name="relative-uri"> |
| 808 |
</xsl:call-template> |
| 809 |
</xsl:otherwise> |
| 810 |
</xsl:choose> |
| 811 |
</xsl:template> |
| 812 |
|
| 813 |
</xsl:stylesheet> |