graphics.xsl 21 KB

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