graphics.xsl 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  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://nwalsh.com/docbook/xsl/ for copyright
  20. 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="dbfo-attribute">
  174. <xsl:with-param name="pis"
  175. select="../processing-instruction('dbfo')"/>
  176. <xsl:with-param name="attribute" select="'background-color'"/>
  177. </xsl:call-template>
  178. </xsl:variable>
  179. <fo:external-graphic>
  180. <xsl:attribute name="src">
  181. <xsl:call-template name="fo-external-image">
  182. <xsl:with-param name="filename">
  183. <xsl:if test="$img.src.path != '' and
  184. not(starts-with($filename, '/')) and
  185. not(contains($filename, '://'))">
  186. <xsl:value-of select="$img.src.path"/>
  187. </xsl:if>
  188. <xsl:value-of select="$filename"/>
  189. </xsl:with-param>
  190. </xsl:call-template>
  191. </xsl:attribute>
  192. <xsl:attribute name="width">
  193. <xsl:choose>
  194. <xsl:when test="$ignore.image.scaling != 0">auto</xsl:when>
  195. <xsl:when test="contains(@width,'%')">
  196. <xsl:value-of select="@width"/>
  197. </xsl:when>
  198. <xsl:when test="@width and not(@width = '')">
  199. <xsl:call-template name="length-spec">
  200. <xsl:with-param name="length" select="@width"/>
  201. <xsl:with-param name="default.units" select="'px'"/>
  202. </xsl:call-template>
  203. </xsl:when>
  204. <xsl:when test="not(@depth) and $default.image.width != ''">
  205. <xsl:call-template name="length-spec">
  206. <xsl:with-param name="length" select="$default.image.width"/>
  207. <xsl:with-param name="default.units" select="'px'"/>
  208. </xsl:call-template>
  209. </xsl:when>
  210. <xsl:otherwise>auto</xsl:otherwise>
  211. </xsl:choose>
  212. </xsl:attribute>
  213. <xsl:attribute name="height">
  214. <xsl:choose>
  215. <xsl:when test="$ignore.image.scaling != 0">auto</xsl:when>
  216. <xsl:when test="contains(@depth,'%')">
  217. <xsl:value-of select="@depth"/>
  218. </xsl:when>
  219. <xsl:when test="@depth">
  220. <xsl:call-template name="length-spec">
  221. <xsl:with-param name="length" select="@depth"/>
  222. <xsl:with-param name="default.units" select="'px'"/>
  223. </xsl:call-template>
  224. </xsl:when>
  225. <xsl:otherwise>auto</xsl:otherwise>
  226. </xsl:choose>
  227. </xsl:attribute>
  228. <xsl:attribute name="content-width">
  229. <xsl:choose>
  230. <xsl:when test="$ignore.image.scaling != 0">auto</xsl:when>
  231. <xsl:when test="contains(@contentwidth,'%')">
  232. <xsl:value-of select="@contentwidth"/>
  233. </xsl:when>
  234. <xsl:when test="@contentwidth">
  235. <xsl:call-template name="length-spec">
  236. <xsl:with-param name="length" select="@contentwidth"/>
  237. <xsl:with-param name="default.units" select="'px'"/>
  238. </xsl:call-template>
  239. </xsl:when>
  240. <xsl:when test="number($scale) != 1.0">
  241. <xsl:value-of select="$scale * 100"/>
  242. <xsl:text>%</xsl:text>
  243. </xsl:when>
  244. <xsl:when test="$scalefit = 1">scale-to-fit</xsl:when>
  245. <xsl:otherwise>auto</xsl:otherwise>
  246. </xsl:choose>
  247. </xsl:attribute>
  248. <xsl:attribute name="content-height">
  249. <xsl:choose>
  250. <xsl:when test="$ignore.image.scaling != 0">auto</xsl:when>
  251. <xsl:when test="contains(@contentdepth,'%')">
  252. <xsl:value-of select="@contentdepth"/>
  253. </xsl:when>
  254. <xsl:when test="@contentdepth">
  255. <xsl:call-template name="length-spec">
  256. <xsl:with-param name="length" select="@contentdepth"/>
  257. <xsl:with-param name="default.units" select="'px'"/>
  258. </xsl:call-template>
  259. </xsl:when>
  260. <xsl:when test="number($scale) != 1.0">
  261. <xsl:value-of select="$scale * 100"/>
  262. <xsl:text>%</xsl:text>
  263. </xsl:when>
  264. <xsl:when test="$scalefit = 1">scale-to-fit</xsl:when>
  265. <xsl:otherwise>auto</xsl:otherwise>
  266. </xsl:choose>
  267. </xsl:attribute>
  268. <xsl:if test="$content-type != ''">
  269. <xsl:attribute name="content-type">
  270. <xsl:value-of select="concat('content-type:',$content-type)"/>
  271. </xsl:attribute>
  272. </xsl:if>
  273. <xsl:if test="$bgcolor != ''">
  274. <xsl:attribute name="background-color">
  275. <xsl:value-of select="$bgcolor"/>
  276. </xsl:attribute>
  277. </xsl:if>
  278. <xsl:if test="@align">
  279. <xsl:attribute name="text-align">
  280. <xsl:value-of select="@align"/>
  281. </xsl:attribute>
  282. </xsl:if>
  283. <xsl:if test="@valign">
  284. <xsl:attribute name="display-align">
  285. <xsl:choose>
  286. <xsl:when test="@valign = 'top'">before</xsl:when>
  287. <xsl:when test="@valign = 'middle'">center</xsl:when>
  288. <xsl:when test="@valign = 'bottom'">after</xsl:when>
  289. <xsl:otherwise>auto</xsl:otherwise>
  290. </xsl:choose>
  291. </xsl:attribute>
  292. </xsl:if>
  293. </fo:external-graphic>
  294. </xsl:template>
  295. <!-- ==================================================================== -->
  296. <xsl:template match="graphic">
  297. <xsl:choose>
  298. <xsl:when test="parent::inlineequation">
  299. <xsl:call-template name="process.image"/>
  300. </xsl:when>
  301. <xsl:otherwise>
  302. <fo:block>
  303. <xsl:if test="@align">
  304. <xsl:attribute name="text-align">
  305. <xsl:value-of select="@align"/>
  306. </xsl:attribute>
  307. </xsl:if>
  308. <xsl:call-template name="process.image"/>
  309. </fo:block>
  310. </xsl:otherwise>
  311. </xsl:choose>
  312. </xsl:template>
  313. <xsl:template match="inlinegraphic">
  314. <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
  315. <xsl:variable name="filename">
  316. <xsl:choose>
  317. <xsl:when test="@entityref">
  318. <xsl:value-of select="unparsed-entity-uri(@entityref)"/>
  319. </xsl:when>
  320. <xsl:otherwise>
  321. <xsl:apply-templates select="@fileref"/>
  322. </xsl:otherwise>
  323. </xsl:choose>
  324. </xsl:variable>
  325. <xsl:choose>
  326. <xsl:when test="@format='linespecific'">
  327. <xsl:choose>
  328. <xsl:when test="$use.extensions != '0'
  329. and $textinsert.extension != '0'">
  330. <xsl:choose>
  331. <xsl:when test="contains($vendor, 'SAXON')">
  332. <stext:insertfile href="{$filename}" encoding="{$textdata.default.encoding}"/>
  333. </xsl:when>
  334. <xsl:when test="contains($vendor, 'Apache Software Foundation')">
  335. <xtext:insertfile href="{$filename}"/>
  336. </xsl:when>
  337. <xsl:otherwise>
  338. <xsl:message terminate="yes">
  339. <xsl:text>Don't know how to insert files with </xsl:text>
  340. <xsl:value-of select="$vendor"/>
  341. </xsl:message>
  342. </xsl:otherwise>
  343. </xsl:choose>
  344. </xsl:when>
  345. <xsl:otherwise>
  346. <a xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"
  347. href="{$filename}"/>
  348. </xsl:otherwise>
  349. </xsl:choose>
  350. </xsl:when>
  351. <xsl:otherwise>
  352. <xsl:call-template name="process.image"/>
  353. </xsl:otherwise>
  354. </xsl:choose>
  355. </xsl:template>
  356. <!-- ==================================================================== -->
  357. <xsl:template match="mediaobject|mediaobjectco">
  358. <xsl:variable name="olist" select="imageobject|imageobjectco
  359. |videoobject|audioobject
  360. |textobject"/>
  361. <xsl:variable name="object.index">
  362. <xsl:call-template name="select.mediaobject.index">
  363. <xsl:with-param name="olist" select="$olist"/>
  364. <xsl:with-param name="count" select="1"/>
  365. </xsl:call-template>
  366. </xsl:variable>
  367. <xsl:variable name="object" select="$olist[position() = $object.index]"/>
  368. <xsl:variable name="align">
  369. <xsl:value-of select="$object/descendant::imagedata[@align][1]/@align"/>
  370. </xsl:variable>
  371. <xsl:variable name="id">
  372. <xsl:call-template name="object.id"/>
  373. </xsl:variable>
  374. <fo:block id="{$id}">
  375. <xsl:if test="$align != '' ">
  376. <xsl:attribute name="text-align">
  377. <xsl:value-of select="$align"/>
  378. </xsl:attribute>
  379. </xsl:if>
  380. <xsl:apply-templates select="$object"/>
  381. <xsl:apply-templates select="caption"/>
  382. </fo:block>
  383. </xsl:template>
  384. <xsl:template match="inlinemediaobject">
  385. <xsl:call-template name="select.mediaobject"/>
  386. </xsl:template>
  387. <!-- ==================================================================== -->
  388. <xsl:template match="imageobjectco">
  389. <xsl:apply-templates select="imageobject"/>
  390. <xsl:apply-templates select="calloutlist"/>
  391. </xsl:template>
  392. <xsl:template match="imageobject">
  393. <xsl:choose>
  394. <xsl:when test="imagedata">
  395. <xsl:apply-templates select="imagedata"/>
  396. </xsl:when>
  397. <xsl:otherwise>
  398. <fo:instream-foreign-object>
  399. <xsl:apply-templates mode="copy-all"/>
  400. </fo:instream-foreign-object>
  401. </xsl:otherwise>
  402. </xsl:choose>
  403. </xsl:template>
  404. <!-- ==================================================================== -->
  405. <xsl:template match="*" mode="copy-all">
  406. <xsl:copy>
  407. <xsl:for-each select="@*">
  408. <xsl:copy/>
  409. </xsl:for-each>
  410. <xsl:apply-templates mode="copy-all"/>
  411. </xsl:copy>
  412. </xsl:template>
  413. <xsl:template match="text()|comment()|processing-instruction()" mode="copy-all">
  414. <xsl:copy/>
  415. </xsl:template>
  416. <!-- ==================================================================== -->
  417. <xsl:template match="imagedata">
  418. <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
  419. <xsl:variable name="filename">
  420. <xsl:call-template name="mediaobject.filename">
  421. <xsl:with-param name="object" select=".."/>
  422. </xsl:call-template>
  423. </xsl:variable>
  424. <xsl:choose>
  425. <xsl:when test="@format='linespecific'">
  426. <xsl:choose>
  427. <xsl:when test="$use.extensions != '0'
  428. and $textinsert.extension != '0'">
  429. <xsl:choose>
  430. <xsl:when test="contains($vendor, 'SAXON')">
  431. <stext:insertfile href="{$filename}" encoding="{$textdata.default.encoding}"/>
  432. </xsl:when>
  433. <xsl:when test="contains($vendor, 'Apache Software Foundation')">
  434. <xtext:insertfile href="{$filename}"/>
  435. </xsl:when>
  436. <xsl:otherwise>
  437. <xsl:message terminate="yes">
  438. <xsl:text>Don't know how to insert files with </xsl:text>
  439. <xsl:value-of select="$vendor"/>
  440. </xsl:message>
  441. </xsl:otherwise>
  442. </xsl:choose>
  443. </xsl:when>
  444. <xsl:otherwise>
  445. <a xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"
  446. href="{$filename}"/>
  447. </xsl:otherwise>
  448. </xsl:choose>
  449. </xsl:when>
  450. <xsl:otherwise>
  451. <xsl:call-template name="process.image"/>
  452. </xsl:otherwise>
  453. </xsl:choose>
  454. </xsl:template>
  455. <!-- ==================================================================== -->
  456. <xsl:template match="videoobject">
  457. <xsl:apply-templates select="videodata"/>
  458. </xsl:template>
  459. <xsl:template match="videodata">
  460. <xsl:call-template name="process.image"/>
  461. </xsl:template>
  462. <!-- ==================================================================== -->
  463. <xsl:template match="audioobject">
  464. <xsl:apply-templates select="audiodata"/>
  465. </xsl:template>
  466. <xsl:template match="audiodata">
  467. <xsl:call-template name="process.image"/>
  468. </xsl:template>
  469. <!-- ==================================================================== -->
  470. <xsl:template match="textobject">
  471. <xsl:apply-templates/>
  472. </xsl:template>
  473. <xsl:template match="textdata">
  474. <xsl:variable name="filename">
  475. <xsl:choose>
  476. <xsl:when test="@entityref">
  477. <xsl:value-of select="unparsed-entity-uri(@entityref)"/>
  478. </xsl:when>
  479. <xsl:otherwise>
  480. <xsl:apply-templates select="@fileref"/>
  481. </xsl:otherwise>
  482. </xsl:choose>
  483. </xsl:variable>
  484. <xsl:variable name="encoding">
  485. <xsl:choose>
  486. <xsl:when test="@encoding">
  487. <xsl:value-of select="@encoding"/>
  488. </xsl:when>
  489. <xsl:otherwise>
  490. <xsl:value-of select="$textdata.default.encoding"/>
  491. </xsl:otherwise>
  492. </xsl:choose>
  493. </xsl:variable>
  494. <xsl:choose>
  495. <xsl:when test="$use.extensions != '0'
  496. and $textinsert.extension != '0'">
  497. <xsl:choose>
  498. <xsl:when test="element-available('stext:insertfile')">
  499. <stext:insertfile href="{$filename}" encoding="{$encoding}"/>
  500. </xsl:when>
  501. <xsl:when test="element-available('xtext:insertfile')">
  502. <xtext:insertfile href="{$filename}"/>
  503. </xsl:when>
  504. <xsl:otherwise>
  505. <xsl:message terminate="yes">
  506. <xsl:text>No insertfile extension available.</xsl:text>
  507. </xsl:message>
  508. </xsl:otherwise>
  509. </xsl:choose>
  510. </xsl:when>
  511. <xsl:otherwise>
  512. <a xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"
  513. href="{$filename}"/>
  514. </xsl:otherwise>
  515. </xsl:choose>
  516. </xsl:template>
  517. <!-- ==================================================================== -->
  518. <xsl:template match="caption">
  519. <fo:block>
  520. <xsl:if test="@align = 'right' or @align = 'left' or @align='center'">
  521. <xsl:attribute name="text-align"><xsl:value-of
  522. select="@align"/></xsl:attribute>
  523. </xsl:if>
  524. <xsl:apply-templates/>
  525. </fo:block>
  526. </xsl:template>
  527. <!-- ==================================================================== -->
  528. <xsl:template name="fo-external-image">
  529. <xsl:param name="filename"/>
  530. <xsl:choose>
  531. <xsl:when test="$passivetex.extensions != 0
  532. or $fop.extensions != 0">
  533. <xsl:value-of select="$filename"/>
  534. </xsl:when>
  535. <xsl:otherwise>
  536. <xsl:value-of select="concat('url(', $filename, ')')"/>
  537. </xsl:otherwise>
  538. </xsl:choose>
  539. </xsl:template>
  540. <!-- Resolve xml:base attributes -->
  541. <xsl:template match="@fileref">
  542. <!-- need a check for absolute urls -->
  543. <xsl:choose>
  544. <xsl:when test="contains(., ':')">
  545. <!-- it has a uri scheme so it is an absolute uri -->
  546. <xsl:value-of select="."/>
  547. </xsl:when>
  548. <xsl:when test="$keep.relative.image.uris != 0">
  549. <!-- leave it alone -->
  550. <xsl:value-of select="."/>
  551. </xsl:when>
  552. <xsl:otherwise>
  553. <!-- its a relative uri -->
  554. <xsl:call-template name="relative-uri">
  555. </xsl:call-template>
  556. </xsl:otherwise>
  557. </xsl:choose>
  558. </xsl:template>
  559. </xsl:stylesheet>